Your question is SQL for Second Highest Value. Start with the requirements and the three 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.
NeenOpal Canada wants a workforce age analysis across its Canadian offices. Write a PostgreSQL query to identify employees with the second-highest distinct age as of 2026-01-01.
Active and whose office is in Canada.DENSE_RANK(), a distinct-age subquery, or a MAX()-based approach.| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Employee identifier |
| full_name | VARCHAR(100) | Employee full name |
| date_of_birth | DATE | Employee date of birth |
| employment_status | VARCHAR(20) | Current employment status |
| department_id | INT | Reference to the employee department |
| office_id | INT | Reference to the employee office |
| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Department identifier |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| office_idPK | INT | Office identifier |
| office_name | VARCHAR(100) | Office name |
| country | VARCHAR(50) | Office country |