Find Employees With Second Highest Salary

Find all employees who have the second-highest salary.

sql

SELECT * FROM employees WHERE salary = ( SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 1 );

This query identifies the second-highest salary using a subquery with LIMIT and OFFSET, then retrieves all employee records that match that specific salary value.

PromptDB can make mistakes. Please double-check responses.