Find Second Most Frequent Employee Salary

Find the second-most frequently occurring salary.

sql

SELECT salary FROM employees GROUP BY salary ORDER BY COUNT(*) DESC LIMIT 1 OFFSET 1;

This query groups the records by salary, counts the occurrences of each, orders them in descending order of frequency, and selects the second record by skipping the first.

PromptDB can make mistakes. Please double-check responses.