Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding the results of 2 results sets

Status
Not open for further replies.

sammy919

Technical User
Dec 7, 2008
1
0
0
Hi just extracting bits of data from 2 sources in Teradata and want to sum them together like you would in a simple addition calculation, but not sure of the syntax to merge the 2 select statements which are working separately ; detailed below
please help..

--1st select stmt
SELECT
SUM(balance) FROM table1
WHERE
date='2008-11-30'
AND
arrears='5 Days'

--2nd select stmt

SELECT
SUM(balance) FROM table2
WHERE
date='2008-11-30'
AND
section='Retail_outlet'
AND
arrears='10 Days'
 
FYR.

SELECT SUM(C1)
FROM
(--1st select stmt
SELECT SUM(balance) c1 FROM table1
WHERE date='2008-11-30' AND arrears='5 Days'
UNION ALL
--2nd select stmt
SELECT SUM(balance) c1 FROM table2
WHERE date='2008-11-30' AND section='Retail_outlet' AND arrears='10 Days') T;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top