Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi friends

I want ot rollup my query by only column of the table and rest should come as it is.
But the problem i am facing the rollup is applied on each column of the table when i am using them in the group by Clause .
Can anyone please suggest a solution?
Posted

 
Share this answer
 
v2
Which version of SQL server are you using?
On SQL Server 2008 you can rollup any column with partitioning.

SQL
select
     sum(aggregation_field) over (partition by GroupingField)
    ,otherfield2
    ,otherfield2
from
    dbo.table


You can group by another field or not group at all.
Note that with this you will get the sum of <aggregation_field> in every row.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900