Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 How to force a select query to abend neo4u DB2 5 Mon Apr 23, 2018 1:36 pm
No new posts SELECT TO MULIPLE OUTFIL speermb DFSORT/ICETOOL 5 Fri Mar 23, 2018 10:44 pm
No new posts Creation of Datasets dynamically on t... Raghu M N DFSORT/ICETOOL 8 Fri Mar 16, 2018 12:56 am
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts How to replace the below query? pkmurali DB2 12 Tue Feb 27, 2018 9:51 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us