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
 

 

Can UNION and COUNT(*) be used in the same select Query.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sushil_ach

New User


Joined: 01 May 2006
Posts: 6

PostPosted: Wed Apr 18, 2007 4:33 pm    Post subject: Can UNION and COUNT(*) be used in the same select Query.
Reply with quote

Hi! friends..
I got two tables say, 'A' and B'.
'A' has column BIN , REGN and QUES.
Let the values be..
BIN QUES REGN
---- ------- -------
1111 Y 1
2222 N 2
3333 N 1
4444 Y 1

'B' has column BIN and QUES
Let the values be..
BIN QUES REGN
---- ------- --------
1111 N 1
2222 N 2
3333 Y 1
5555 N 2

I want to find how many Y's and N's are there for QUES in Table 'A', also if the BIN is not found in 'A' the query should fetch the BIN from table 'B'.

In my query i'm using COUNT(*) and UNION which is getting the duplicates which i dont want

Answer for the above example should be like....

REGN QUES
-------- --------
1 N 2
1 Y 1
2 N 2
Back to top
View user's profile Send private message

sushil_ach

New User


Joined: 01 May 2006
Posts: 6

PostPosted: Wed Apr 18, 2007 4:44 pm    Post subject:
Reply with quote

Answer for the above example should be like....

REGN QUES
-------- --------
1 -------N --------------2
1 -------Y --------------1
2 -------N ------------- 2

THANX for the help in advance... icon_smile.gif
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 Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Display FTP Session Count within TSO Yolanda Harvey TSO/ISPF 3 Fri Mar 10, 2017 10:31 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am


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