Saturday, February 25, 2012

need -> max(sum(salary)) query

hi

i have a table employee:

dept ename salary
-- --- ---
10 A 2500
20 B 3500
30 C 4000
20 D 5500
10 E 4500
30 F 5200

FIRST QUERY:
select dept,sum(salary) from employee group by dept

the above one is working fine..

after working the first query output,
i want to select the dept,max(sum(salary)) from the table...

how?? could any one send me immediately...

thanks in advancethe below one query will give only the max(sum(salay))

-----
select max(sal) from (select sum(salary) as sal from employee
group by dept) as a
-------

but i need - Which DEPT has the max(sum(salary)) ??

need these two values:

dept, max(sum(salary))

thanks|||select top 1
dept
, sum(salary)
from employee
group
by dept
order
by sum(salary) desc|||hi
it works .

thanks rudy....

No comments:

Post a Comment