locked
Naming a COMPUTE SUM column result RRS feed

  • 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.

    COMPUTE

     

    SUM(incurred_total) BY location

    sum
    ----------
    476.93

    Wednesday, July 8, 2009 8:02 PM

Answers

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 location

    Wednesday, 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/
    Wednesday, July 8, 2009 8:23 PM