Easy · 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
20 free core interview problems with full runner & lessons; explore the complete 380+ library with Pro.