1SELECT firstname, MAX(salary)
2FROM department d LEFT OUTER JOIN employee e
3ON (d.department_id = e.department_id)
4GROUP BY department_id;
1--Find out the name of top earner in each departments
2--Output has Name, Department name and max salary of the department
3
4SELECT E.FIRST_NAME , D.DEPARTMENT_NAME, E.SALARY
5FROM EMPLOYEES E
6JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
7WHERE SALARY IN(SELECT MAX(E.SALARY)
8FROM EMPLOYEES E
9JOIN DEPARTMENTS D ON E.DEPARTMENT_ID = D.DEPARTMENT_ID
10GROUP BY DEPARTMENT_NAME);
1SELECT salary, first_name, last_name FROM employees
2ORDER BY salary DESC LIMIT 3;