Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Second highest salary

SQL data engineering interview problem. Difficulty: intermediate. Pattern: Subqueries. About 12 minutes. Part of the Pro drill bank.

Return one column second_highest_salary: the second highest distinct salary in employees. If multiple employees share the highest salary, still take the next lower distinct value.

Examples

Input: employees name | salary Alice Chen | 120000 Dan Park | 110000 Omar Ali | 105000 Bob Kumar | 95000 Eve Ng | 95000 Output: second_highest_salary | 110000 | Why this passes: Distinct ordered salaries: 120000, 110000, 105000, 95000. Second is 110000.

Topics: lakebench, sql, nth, salary.

More SQL interview questions · All interview problems · Learn data engineering

intermediate

Second highest salary

Interview-style drill: Find the second highest distinct salary.

Return one column `second_highest_salary`: the second highest distinct salary in `employees`. If multiple employees share the highest salary, still take the next lower distinct value.