Page 1 of 1

Db2 Query

PostPosted: Mon Sep 06, 2010 12:49 pm
by nm992
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?

Re: Db2 Query

PostPosted: Mon Sep 06, 2010 3:28 pm
by GuyC
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)