I have a (sql server 2008) query as follows:
Select *, column1+column2 as alias1
From complaints
Order by
Case
When @param1 = 'filedate' then filedate
When @param1 = 'calc' then alias1
End
This doesn’t work, because ordering on an alias in a case statement is not allowed, it doesn’t recognize alias1.
Is there another way this can be done?
Thanks
either put it in a CTE and then order by…
or just duplicate what the alias actually refers to…