This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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)