sum of two Queries
i acn use
select a,b,c from ABC
unoin
select a,b,c from DEF
is there any method other than following. to ADD values of above queries
ie 1ineed output in a+a,b+b,c+c
iget result by
select sum(t.a),sum(t.b),sum(t.c) from(select a,b,c from ABC
unoin
select a,b,c from DEF
)as t
and select a+(select a from DEF),b+(select b from DEF),c+(select c from DEF) from ABC
above two gives result but in my case its not correct help me pls???
Vilas GitePosted Jun 16, 2011, 4:19 AM
(
NO1 NUMERIC(7,2),
NO2 NUMERIC (7,2),
NO3 NUMERIC (7,2),
NOSUM NUMERIC (7,2)
)
CREATE TABLE TBL2
(
A NUMERIC(7,2),
B NUMERIC (7,2),
C NUMERIC (7,2),
TABL2SUM NUMERIC (7,2)
)
SELECT * FROM TBL1
SELECT * FROM TBL2
SELECT SUM(TBL1.NO1+TBL2.A),sum(TBL1.NO2+TBL2.B),sum(TBL1.NO3+TBL2.C)
from TBL1,TBL2
-----------------------------------------------
If this reply solve your post…then "MARK AS ANSWER"!
Neel SreerajPosted Jun 15, 2011, 7:44 AM
Neel SreerajPosted Jun 15, 2011, 7:43 AM
Try the following,
select sum(ABC.a+DEF.a),sum(ABC.b+DEF.b),sum(ABC.c+DEF.c) from #temp1,ABC