Query Employees With Higher Salary Than Department

Find employees whose salary is higher than every employee in another department.

sql

SELECT name, salary FROM employees WHERE salary > ALL ( SELECT salary FROM employees WHERE department_id = 2 );

This query selects the "name" and "salary" from the "employees" table where the salary is strictly greater than the maximum salary found in the department with an ID of 2.

PromptDB can make mistakes. Please double-check responses.