Medium · Database
Second Highest Distinct Salary
Given Employee(id, salary), return one Salary row containing the second highest distinct salary. Return no rows when fewer than two distinct salaries exist.
Examples
Example 1
{
"employees": [
{"id": 1, "salary": 100},
{"id": 2, "salary": 100},
{"id": 3, "salary": 80},
{"id": 4, "salary": 50}
]
}Output: [{"Salary":80}]
Example 2
{
"employees": [
{"id": 5, "salary": 40},
{"id": 6, "salary": 40}
]
}Output: []
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.