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 |
|
txk2601
Starting Member
19 Posts |
Posted - 2009-03-31 : 05:46:50
|
| Hi, I have a problem with T-sql. I have a table as followingID | Value1 | Value 2 ...1 | 12 | 232 | 24 | 063 | 01 | 36...Now, i wan't add total row in to this table. as followingID | Value1 | Value 2 ...1 | 12 | 232 | 24 | 063 | 01 | 36NULL | 37 | 65I don't know way to make it. Please help me! Thank alot |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-31 : 05:54:00
|
[code]DECLARE @Sample TABLE ( ID INT, Value1 INT, Value2 INT )INSERT @SampleSELECT 1, 12, 23 UNION ALLSELECT 2, 24, 06 UNION ALLSELECT 3, 01, 36SELECT ID, Value1, Value2FROM @SampleUNION ALLSELECT NULL, SUM(Value1), SUM(Value2)FROM @Sample[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-31 : 05:55:47
|
| 1 Do this in Reports2 Read about CUBE operator3 SELECT ID,value1,value2 ...UNION ALLSELECT NULL,sum(value1),sum(value2) ...MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-31 : 05:56:09
|
MadhivananFailing to plan is Planning to fail |
 |
|
|
txk2601
Starting Member
19 Posts |
Posted - 2009-03-31 : 23:11:33
|
| Thanks Peso and Madhivanan very much! |
 |
|
|
|
|
|
|
|