Your question is SQL Top-N Highest Salary. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
YASH Technologies needs a workforce report showing its highest-paid active employees. Write a PostgreSQL query to identify the first three active employees by salary and include their department names.
employment_status is Active.salary from highest to lowest using a window function. Treat employees with equal salaries deterministically by ordering by employee_id as a tie-breaker.LEFT JOIN so an employee is not removed if the department reference is missing. Sort the final result by salary descending and employee ID ascending.| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's full name |
| department_id | INT | Referenced department identifier |
| salary | NUMERIC(12,2) | Annual employee salary |
| employment_status | VARCHAR(20) | Current employment status |
| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department display name |