View previous topic :: View next topic
|
Author |
Message |
CICS fan
New User
Joined: 03 Apr 2008 Posts: 82 Location: United States
|
|
|
|
I have a DB2 table:
Columns:
Emp ID
Emp Name
Emp Age
Emp Manager
Manager's ID
I ned all Emp ID and Name whose Age is greater than their respective managers age.
Pls suggest the best solution. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
What have you tried so far?
Do a self join of the table on emp_id and manager_id with the age condition or else use a correlated subquery for the age . |
|
Back to top |
|
|
CICS fan
New User
Joined: 03 Apr 2008 Posts: 82 Location: United States
|
|
|
|
I am in sea with this. Could u be a bit specific kindly. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Quote: |
I am in sea with this
|
??
Code: |
SELECT EMP_ID FROM TABLE A
WHERE EMP_AGE > (SELECT MANAGER_AGE FROM TABLE B
WHERE EMP_ID = A.EMP_ID)
|
|
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hello There,
I think below query will give desired results
Code: |
Select EMP_ID from Table A
Where Emp_Age >( Select Emp_Age From Table B
Where A.Manager's_ID =B.Emp_id) |
|
|
Back to top |
|
|
|