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

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


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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 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 RC query -Time column CA Products 3
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top