programming-examples/sql/SubqueriesHRDatabase/Write a query in SQL to display the the details of those departments which max salary is 7000 or above for those employees.sql

14 lines
500 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
/*Write a query in SQL to display the the details of those departments which max salary is 7000 or above for those employees
who already done one or more jobs.
*/
SELECT *
FROM departments
WHERE department_id IN
(SELECT department_id
FROM employees
WHERE employee_id IN
(SELECT employee_id
FROM job_history)
GROUP BY department_id
HAVING MAX(salary) >=7000);