Db2 Query



IBM's flagship relational database management system

Db2 Query

Postby nm992 » Mon Sep 06, 2010 12:49 pm

I have 2 tables..

table 1:

Eno Ename Esalary Edept with Eno as Primary Key

Table 2:
ManagrID Managersal Mandept with each dept being unique

Note: Each dept is asscoiated with a singlt manager.

Now I want table 3 as:

Manager ID Ename (who is withdrawing Maximum salary for a particular dept).

Can someone please help me with the query?
nm992
 
Posts: 43
Joined: Sun Jul 11, 2010 11:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Db2 Query

Postby GuyC » Mon Sep 06, 2010 3:28 pm

select * from
 Tab2 M join  Tab1 E on M.mandept = e.edept
where e.Esal = (select max(a.Esal) from tab1 A where A.edept = e.edept)
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post