Sum command from Sqlserver [Resolved]

Posted by Vanchi050585 under Sql Server on 4/7/2011 | Points: 10 | Views : 1254 | Status : [Member] | Replies : 2
hi Friends,

i have written query like below:
SELECT Sum1,Sum2,Sum3,Sum4,Sum5,Sum6,Sum7,Sum8,Sum9,Sum10,Sum11,Sum1+Sum2+Sum3+Sum4+Sum5+Sum6+Sum7+Sum8+Sum9+Sum10+Sum11 as Total
(SELECT SUM(Points) as Sum1 FROM tblClassifieds
WHERE Author='Vanchi') T1 CROSS JOIN
(SELECT SUM(Points) as Sum2 FROM tblCollege
WHERE Author='Vanchi') T2 CROSS JOIN
(SELECT SUM(Points) as Sum3 FROM tblForum
WHERE Author='Vanchi') T3 CROSS JOIN
(SELECT SUM(Points) as Sum4 FROM tblForumResponse
WHERE responseby='Vanchi') T4 CROSS JOIN
(SELECT SUM(Points) as Sum5 FROM tblKnowledge
WHERE Author='Vanchi') T5 CROSS JOIN
(SELECT SUM(Points) as Sum6 FROM tblmusicinfo
WHERE Author='Vanchi') T6 CROSS JOIN
(SELECT SUM(Points) as Sum7 FROM tblpostjob
WHERE Author='Vanchi') T7 CROSS JOIN
(SELECT SUM(Points) as Sum8 FROM tblRecipe
WHERE Author='Vanchi') T8 CROSS JOIN
(SELECT SUM(Points) as Sum9 FROM tblSchool
WHERE Author='Vanchi') T9 CROSS JOIN
(SELECT SUM(Points) as Sum10 FROM tblUniversity
WHERE Author='Vanchi') T10 CROSS JOIN
(SELECT SUM(Points) as Sum11 FROM tblwavesinfo
WHERE Author='Vanchi') T11

but the result was displayed like below:
Sum1 Sum2 Sum3 Sum4 Sum5 Sum6 Sum7 Sum8 Sum9 Sum10 Sum11 Total
5 6 12 NULL 12 NULL NULL 6 6 4 2 NULL

here Total was diaplayed as NULL
but i want to show the Total=53

anybody tell the procedure of query

Thanks in Advance



Posted by: Karthikanbarasan on: 4/11/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 50


Check with the inbuild ISNULL function and replace with 0... so that u can easily sort out


Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 4/8/2011 [Member] [MVP] Starter | Points: 25

hi Vanchi050585

i think u change null to 0 . . so you find out ur result . .

Best Regard's

Vanchi050585, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response