Second Highest Salary

Second Highest Salary

Easy Programming Interview DBMS 22 views
Explanation Complexity

Problem Statement

Table: Employees(emp_id, salary). Return the second highest distinct salary. If it does not exist, return NULL.

Input Format

SQL tables are described in the question.

Output Format

Write the SQL query.

Input / Output Format

Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.

Example Solution (Public)

Programming Interview
SELECT MAX(salary) AS second_highest
FROM Employees
WHERE salary < (SELECT MAX(salary) FROM Employees);

Official Solution Code

SELECT MAX(salary) AS second_highest
FROM Employees
WHERE salary < (SELECT MAX(salary) FROM Employees);
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.