I want to give columns aliases without knowing their names, but only their number in the table.
Something like this:
select firstColumn as myId, secondColumn as myName, thirdColumn as myLastName
where I don't know the actual names of the columns
(I understand that the need sounds strange. And yes I can know the names of the columns. This is a technical question, please answer if you know the technical answer, regardless of the motivation. Thank you!)
The closest you could do is use INFORMATION_SCHEMA.COLUMNS to find the column name from the ordinal position. I realize this isn't what you asked for, but I think it may be as close as you can get. For instance, you could build a select statement having the 1st, 2nd and 5th columns as follows: