How does SQL Server allow the same alias in the same SELECT statement?
I was doing some queries with Dapper and came across a use case where I needed to return different columns using the same alias to be able to map into different objects with the same property name e.g. Teacher.Name
and Student.Name
. I was also using a view and it did complain about not allowing columns with the same name. So I aliased the columns to different names in the view and then when doing a select from the view, I aliased them back to the same name and it worked, which I did not expect. I also couldn’t find any resources on this.