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

后端 未结 12 1817
慢半拍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:09

    You pass the expression you want to group by rather than the alias

    SELECT       LastName + ', ' + FirstName AS 'FullName'
    FROM         customers
    GROUP BY      LastName + ', ' + FirstName
    

提交回复
热议问题