Your question is Second Maximum Salary Query. 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.
HashedIn's engineering dashboard needs to identify active employees whose compensation is the second-highest distinct salary in the company. Write a PostgreSQL query that also displays each employee's department when available.
is_active is TRUE and salary is not NULL.employee_id ascending.| Column | Type | Description |
|---|---|---|
| employee_idPK | INTEGER | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's full name |
| salary | NUMERIC(12,2) | Annual employee salary |
| department_id | INTEGER | Referenced department identifier |
| is_active | BOOLEAN | Whether the employee is currently active |
| Column | Type | Description |
|---|---|---|
| department_idPK | INTEGER | Unique department identifier |
| department_name | VARCHAR(100) | Department name |