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

Query to fetch only if employee has more than one record


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abraralum

New User


Joined: 19 Dec 2010
Posts: 42
Location: Bangalore

PostPosted: Fri Aug 05, 2011 12:43 pm
Reply with quote

Hi..

I am looking for some pointers here please ...

EMP_ID EMP_NM EMP_Project_ID
1 XXX 888
1 XXX 999
1 XXX 777

I will have to fetch the records of the employee only if the employee is working for more than one project.... i.e, my query shoud satisfy teh condition
EMP_ID = 1,
EMP_NM = 'XXX',
Row count (EMP_Project_ID) > 0

Please advise how can I place the last condition in Sql query.
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Fri Aug 05, 2011 2:36 pm
Reply with quote

Code:


SELECT EMP_ID, EMP_NM , COUNT(*)
FROM EMP
GROUP BY EMP_ID, EMP_NM
HAVING COUNT(*) > 1
WITH UR;
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top