programming-examples/sql/SubqueriesHRDatabase/Write a query which is looking for the names of all employees whose salary is greater than 50 of their departments total salary bill.sql
2019-11-18 14:05:53 +01:00

10 lines
347 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*Write a query which is looking for the names of all employees whose salary is greater than 50% of their departments
total salary bill.
*/
SELECT e1.first_name, e1.last_name
FROM employees e1
WHERE salary >
( SELECT (SUM(salary))*.5
FROM employees e2
WHERE e1.department_id=e2.department_id);