Hey guys,
I am writing a query that performs multiple SUMS, and want to combine the summations all into one big query.
I can't figure out the syntax to do this. I tried UNION this way:
It kinda works, but it lumps everything under one column as "TOTAL TAPERS DEPOSIT AMOUNT"
Is there any way to do this?
I am writing a query that performs multiple SUMS, and want to combine the summations all into one big query.
I can't figure out the syntax to do this. I tried UNION this way:
Code:
SELECT sum(A.ANTY_PYMT_tot_AMT) AS "TOTAL TAPERS DEPOSIT AMOUNT"
FROM DSNP.PR01_T_ANTY_PYMT A,
DSNP.PR01_T_RECIP_SYS B
WHERE A.RECIP_SSN_NBR=B.RECIP_SSN_NBR
AND A.BENEF_SEQ_NBR=B.BENEF_SEQ_NBR
and b.agty_sys_cd = 'TAPERS'
AND A.ANTY_PYMT_DT BETWEEN '2010-02-01' AND '2010-02-28'
AND A.ANTY_PYMT_STAT_CD = 'A'
UNION
SELECT sum(A.ANTY_PYMT_tot_AMT) AS "TOTAL TAJRS DEPOSIT AMOUNT"
FROM DSNP.PR01_T_ANTY_PYMT A,
DSNP.PR01_T_RECIP_SYS B
WHERE A.RECIP_SSN_NBR=B.RECIP_SSN_NBR
AND A.BENEF_SEQ_NBR=B.BENEF_SEQ_NBR
and b.agty_sys_cd = 'TAJRS'
AND A.ANTY_PYMT_DT BETWEEN '2010-02-01' AND '2010-02-28'
AND A.ANTY_PYMT_STAT_CD = 'A'
It kinda works, but it lumps everything under one column as "TOTAL TAPERS DEPOSIT AMOUNT"
Is there any way to do this?