var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: need -> max(sum(salary)) query
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
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 advance
Re: need -> max(sum(salary)) query
the 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:
select top 1
, sum ( salary )
by sum ( salary ) desc
it works .
select d.DepartmentName as department,SUM(e.Salary) as 'total salary' from Emplyee e inner join Department d on e.DeptId=d.DepartmentID group by d.DepartmentName having sum(e.Salary) = (select max(sal) from (select sum(Salary) as sal from Emplyee group by DeptId) as a)
umair, that's really quite complicated as compared with post #3 which works just fine
it's also eight years late
nice try, though
"find the top 10 buying section sum " "having " "max income in between 1mar3012 and 1apr2013"
buying section date money
It might be late and more complicated, but it's more accurate. Post number 3 ignores the case where two or more departments have the same max salary.
Originally Posted by