Your question is SQL Grouping and Ranking. 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.
United Airlines is reviewing employee compensation data for workforce reporting. Write a PostgreSQL query to identify the second-highest distinct salary in the employee_compensation table.
annual_salary is NULL.The query should treat tied salaries as one salary level. For example, if multiple employees earn the highest salary, the next distinct salary is still the second-highest salary.
| Column | Type | Description |
|---|---|---|
| employee_idPK | INTEGER | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's name |
| annual_salary | NUMERIC(12,2) | Annual salary in U.S. dollars |
| work_group | VARCHAR(50) | United Airlines organizational group |