I have an employee table with following fields
now i want to write a query on this table to get me the department id which gives maximum total salary to its employees. I wrote below query.
mysql> select sum(e1.salary), e1.departmentid from employee e1 group by e1.departmentid having sum(e1.salary) > 50000;
above query generates proper result when maximum sum salary of a department is > 50000 but as i wrote above i want to generate the department which gives maximum salary (i dont want to compare with 50000)