Author |
Topic |
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-05-18 : 05:15:40
|
DECLARE @STUDENT TABLE(SID INT,SNAME VARCHAR(20),MARK1 INT,MARK2 INT,MARK3 INT,MARK4 INT,MARK5 INT)INSERT INTO @STUDENT select 1,'SONE',80,70,50,60,70 UNION allselect 2,'STWO',60,65,85,76,80 UNION allselect 3,'Sthree',60,65,85,76,80 from the above table i need to get the output columnwise total and rowwise total along with the usual select statment..1 sone 80 70 50 60 70 3302 stwo 60 65 85 76 80 3263 sthree 60 65 85 76 80 326 200 200 220 212 190 is it possible to get this kind of output. how ? |
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-18 : 05:42:55
|
Somthing like this DECLARE @STUDENT TABLE(SID INT,SNAME VARCHAR(20),MARK1 INT,MARK2 INT,MARK3 INT,MARK4 INT,MARK5 INT)INSERT INTO @STUDENTselect 1,'SONE',80,70,50,60,70 UNION allselect 2,'STWO',60,65,85,76,80 UNION allselect 3,'Sthree',60,65,85,76,80 Select SID,SName,Mark1,Mark2,Mark3,Mark4,Mark5,(Mark1+Mark2+Mark3+Mark4+Mark5) As Total From @StudentUnion All Select '','Horizontal Total',Sum(Mark1),Sum(Mark2),Sum(Mark3),Sum(Mark4),Sum(Mark5),Sum(Mark1+Mark2+Mark3+Mark4+Mark5) As Total From @Student If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-18 : 05:46:19
|
Where do you want to show the data?If you use Reports make use of Summary OptionMadhivananFailing to plan is Planning to fail |
|
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-05-18 : 05:48:56
|
Thanks. i will try my requirment with the help of the above code |
|
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-05-18 : 05:50:48
|
Output of this SP will get displayed in my windows forms..Anyway, the previous post will help me i believequote: Originally posted by madhivanan Where do you want to show the data?If you use Reports make use of Summary OptionMadhivananFailing to plan is Planning to fail
|
|
|
|
|
|