Your question is Writing SQL for Ranking. 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.
TCS iON is reviewing compensation among its active employees. Write a PostgreSQL query to find every active employee whose salary is the second-highest distinct salary in the employee table.
Active before calculating the salary ranking.| Column | Type | Description |
|---|---|---|
| employee_idPK | INTEGER | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's full name |
| salary | NUMERIC(12,2) | Annual salary |
| department_id | INTEGER | Reference to the employee's department |
| employment_status | VARCHAR(20) | Current employment status |
| Column | Type | Description |
|---|---|---|
| department_idPK | INTEGER | Unique department identifier |
| department_name | VARCHAR(100) | Department name |