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