SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Find Top 2 Employees by Salary in Each Department

Build mastery in Ranking Nth Value with this scenario-based SQL challenge and live execution support.

Problem Statement

Return the top 2 highest-paid employees in EACH department. If a department has a tie at rank 2, return ALL tied employees (so the result may exceed 2 per department). Show department_id, first_name, last_name, salary, dept_rank — ordered by department_id, dept_rank, employee_id.

Relevant Tables

employees

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: