How do I perform a GROUP BY on an aliased column in MS-SQL Server?

后端 未结 12 1832
慢半拍i
慢半拍i 2020-11-29 00:20

I\'m trying to perform a group by action on an aliased column (example below) but can\'t determine the proper syntax.

SELECT       LastName + \', \'         


        
12条回答
  •  暖寄归人
    2020-11-29 01:16

    If you want to avoid the mess of the case statement being in your query twice, you may want to place it in a User-Defined-Function.

    Sorry, but SQL Server would not render the dataset before the Group By clause so the column alias is not available. You could use it in the Order By.

提交回复
热议问题