IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sum up the count of three tables


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Neena John

New User


Joined: 20 Nov 2008
Posts: 13
Location: bangalore

PostPosted: Thu Jul 16, 2009 2:25 pm
Reply with quote

There are three tables
Current,History and archive.The contents of these tables are consolidated in one table called Full.

I need to write a query in which i need to
sum up the record count of Current,History and archive

For example
SELECT COUNT(*) AS C
FROM CURRENT
UNION
SELECT COUNT(*) AS H
FROM HISTORY
UNION
SELECT COUNT(*) AS A
FROM ARCHIVE;

Now i need to sum up the count values(c,h,a) in the same query.
Can anyone help me on this?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Thu Jul 16, 2009 3:09 pm
Reply with quote

Neena,

Try something like this.
Code:
SELECT SUM(CNT) FROM (                           
SELECT COUNT(*) AS CNT FROM BOBT1.COUNTRY         
UNION ALL                                         
SELECT COUNT(*) AS CNT FROM BOBT1.EMPLOYEE ) AS A


Sushanth
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Need to fetch data from so many DB2 t... DB2 9
Search our Forums:

Back to Top