Your question is Second Highest Without Aggregates. Start with the requirements and the one table 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.
AvidXchange wants to review compensation bands by department. Write a PostgreSQL query to find the second highest distinct salary in each department, without using any aggregate functions such as MAX() or COUNT().
department_name.| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Primary key for the employee |
| employee_name | VARCHAR(100) | Employee name |
| department_name | VARCHAR(100) | Department name |
| salary | INT | Employee salary, may repeat across employees |
| hire_date | DATE | Employee hire date |