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 write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm

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