Interview Query

2nd Highest Salary

68
Have you seen this question before?

Write a SQL query to select the 2nd highest salary in the engineering department. If more than one person shares the highest salary, the query should select the next highest salary.

Example:

Input:

employees table

Column Type
id INTEGER
first_name VARCHAR
last_name VARCHAR
salary INTEGER
department_id INTEGER

departments table

Column Type
id INTEGER
name VARCHAR

Output:

Column Type
salary INTEGER
Next question: Project Budget Error
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query