Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sum up the count of three tables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Sum up the count of three tables
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: 1013
Location: India

PostPosted: Thu Jul 16, 2009 3:09 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts CICS Transaction attach count of supp... lind sh CICS 1 Wed Jun 21, 2017 1:33 pm
No new posts Identify top 30 big tables or indexes... ashek15 DB2 0 Fri Jun 16, 2017 10:01 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us