Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Top three salaries

SQL data engineering interview problem. Difficulty: beginner. Pattern: Sorting. About 8 minutes. Free to practice.

List the top 3 highest-paid employees from employees. Columns: name, department, salary. Order by salary descending, then name. Exclude NULL salaries.

Requirements

  • Ties on salary are broken by name ascending in the ORDER BY.

Constraints

  • Return exactly these columns: name, department, salary.

Examples

Input: employees name | department | salary Alice Chen | Engineering | 120000 Dan Park | Engineering | 110000 Omar Ali | Sales | 105000 Bob Kumar | Engineering | 95000 Eve Ng | Engineering | 95000 Max Reed | Sales | NULL Output: name | department | salary Alice Chen | Engineering | 120000 Dan Park | Engineering | 110000 Omar Ali | Sales | 105000 Why this passes: LIMIT 3 after sorting by salary descending keeps the three richest non-null rows.

Topics: lakebench, sql, order by, limit, top-n.

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

beginner

Top three salaries

Interview-style drill: Return the three highest-paid employees.

List the top 3 highest-paid employees from `employees`. Columns: `name`, `department`, `salary`. Order by `salary` descending, then `name`. Exclude NULL salaries.