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 |
|
sqldev6363
Yak Posting Veteran
54 Posts |
Posted - 2009-01-04 : 12:59:45
|
| i have a table structure like thistype B1 B2 B3 Totalcan 0 0 1 1kod 2 5 1 8son 9 7 0 16Tot 11 12 2 25I am getting the total of the column 'Total' of each row, but how i can get the total of the row 'tot' of each column and the last value is 25 i.e, grand total, sum of total rows.I need a query for that can any one help me on thatdev |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
chrianth
Yak Posting Veteran
50 Posts |
Posted - 2009-01-04 : 21:48:18
|
| you can have it...select sum(B1) B1, sum(B2) B2, sum(B3) B3, sum(Total) Totalfrom Tablewhere Type in ('cad','kod','son')the output would be the grandtotal of columns B1,B2,B3 and Total for the type under cad,kod and son.HTH :) |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-01-04 : 23:33:53
|
| declare @temp table (type varchar(32), B1 int, B2 int, B3 int, Total int )insert into @tempselect 'can', 0, 0, 1, 1 union allselect 'kod', 2, 5, 1, 8 union allselect 'son', 9, 7, 0, 16--select * from @tempselect type,sum(B1) AS B1, sum(B2) AS B2, sum(B3) AS B3, sum(Total) AS Totalfrom @temp group by [type] with cube |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-01-05 : 02:17:29
|
| If you use reporting service, do the totalling thereMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|