Second highest salary using subquery

Second highest salary using subquery

Medium SQL Subqueries 18 views
Explanation Complexity

Problem Statement

Return the second highest distinct salary from Employees.

Input Format

SQL query

Output Format

Result set

Example

Employees(salary)
One row

Constraints

Use subquery with DISTINCT

Input / Output Format

Input Format
SQL query
Output Format
Result set
Constraints
Use subquery with DISTINCT

Examples

Input:
Employees(salary)
Output:
One row

Example Solution (Public)

SQL
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.