Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ranalk
Starting Member
49 Posts |
Posted - 2012-08-05 : 10:46:09
|
Hi,I have a table with 10 columns (int, subject) and 50 rows (clients).I would like to add a row in the end that will summarize the amount of each column.E.g.Customer | Cheese | Milk | BreadMike | 5 | 7 | 10Sam | 1 | 2 | 0Total | 6 | 9 | 10Thanks in advance |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-05 : 14:49:25
|
use with cube or with rollup------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
ranalk
Starting Member
49 Posts |
Posted - 2012-08-06 : 03:12:45
|
Hi,I saw you pivoting solution but in my example there is no need to use pivoting.Cube and RollUp are summarizing each row and column.I need to have just the total of each column and marked in the example above, without referring to the customer name.can you assist?thanks! |
 |
|
ranalk
Starting Member
49 Posts |
Posted - 2012-08-06 : 03:53:25
|
Ok , I managed by adding union all select 'total',Sum(cheese),Sum(milk),Sum(Bread) from table |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-06 : 09:47:32
|
cool...the principle is same even if you dont require pivotting------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|