Your question is SQL Rank Per Department. 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.
Infocepts Workforce Analytics needs a department-level salary benchmark. Write a PostgreSQL query to return the second-highest distinct salary for every department.
DENSE_RANK() or an equivalent ranking approach so tied salaries share the same rank.NULL before ranking.NULL in that result column.| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee full name |
| department_id | INT | Department assigned to the employee |
| salary | NUMERIC(12,2) | Annual employee salary |