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 |
sreekanth939
Starting Member
12 Posts |
Posted - 2009-04-23 : 03:06:18
|
sum of two Queriesi acn use select a,b,c from ABCunoinselect a,b,c from DEFis there any method other than following. to ADD values of above queris ..ie 1ineed output in a+a,b+b,c+ciget result by select sum(t.a),sum(t.b),sum(t.c) from(select a,b,c from ABCunoinselect a,b,c from DEF)as tand select a+(select a from DEF),b+(select b from DEF),c+(select c from DEF) from ABCbut above two is query gives result but in my case its not correct help me pls? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-23 : 03:09:00
|
[code]SELECT SUM(A), SUM(B), SUM(C)FROM ( SELECT SUM(A) AS A, SUM(B) AS B, SUM(C) AS C FROM Table1 UNION ALL SELECT SUM(A) AS A, SUM(B) AS B, SUM(C) AS C FROM Table2 ) AS d[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|
|