3
Answers

TWO Queries

Photo of Sreekanth

Sreekanth

16y
2.3k
1

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???

Answers (3)

0
Photo of Vilas Gite
NA 2.9k 394k 13y
CREATE TABLE TBL1
(
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"!


0
Photo of Neel Sreeraj
NA 66 0 13y
#temp1-->DEF
0
Photo of Neel Sreeraj
NA 66 0 13y


Try the following, 


select sum(
ABC.a+DEF.a),sum(ABC.b+DEF.b),sum(ABC.c+DEF.c) from #temp1,ABC

Next Recommended Forum