Answered by:
Naming a COMPUTE SUM column result

Question
-
Is there a way to name the result column for a COMPUTE SUM command (see below). The column name defaults to "sum" but this is confusing when using multiple compute sum commands to group and subgroup query results. Thanks.
COMPUTESUM(incurred_total) BY location
sum
----------
476.93Wednesday, July 8, 2009 8:02 PM
Answers
-
You are better off using the with rollup option in conjunction with the group by clause. It is written that compute will be removed from the next version of SQL Server. Here is the link on using rollup.
http://msdn.microsoft.com/en-us/library/bb522495.aspx
http://jahaines.blogspot.com/- Marked as answer by Jinchun ChenMicrosoft employee Monday, July 20, 2009 2:45 AM
Wednesday, July 8, 2009 8:23 PM
All replies
-
Select Sum(x) As yourname
JP
Please click the Mark as Answer button if a post solves your problem!Wednesday, July 8, 2009 8:05 PM -
Tried that but it doesn't work...probably because of the "by location"
note the full command is COMPUTE SUM(incurred_total) BY locationWednesday, July 8, 2009 8:11 PM -
According to the docs, this feature is going to be removed. To do this sort of aggregation, you want to use SQL.
JP
Please click the Mark as Answer button if a post solves your problem!Wednesday, July 8, 2009 8:14 PM -
You are better off using the with rollup option in conjunction with the group by clause. It is written that compute will be removed from the next version of SQL Server. Here is the link on using rollup.
http://msdn.microsoft.com/en-us/library/bb522495.aspx
http://jahaines.blogspot.com/- Marked as answer by Jinchun ChenMicrosoft employee Monday, July 20, 2009 2:45 AM
Wednesday, July 8, 2009 8:23 PM