101
0/304
Loading content...
A compensation analytics service stores one row per employee in a table named employees.
Table: employees
Your task is to identify employees who sit in the second salary tier of their department.
Definition of second salary tier:
Important behavior:
Return exactly these columns in this order:
Final ordering:
Supported submission environments:
employees:
| emp_id | salary | dept |
|--------|--------|----------|
| 11 | 120000 | Platform |
| 12 | 135000 | Platform |
| 13 | 135000 | Platform |
| 14 | 150000 | Platform |
| 21 | 90000 | Risk |
| 22 | 90000 | Risk |
| 23 | 87000 | Risk |
| 31 | 76000 | Growth |
| 32 | 81000 | Growth |
| 41 | 50000 | Legal |[
{"emp_id":12,"dept":"Platform"},
{"emp_id":13,"dept":"Platform"},
{"emp_id":23,"dept":"Risk"},
{"emp_id":31,"dept":"Growth"}
]Platform runner-up salary is 135000 and includes two employees. Risk runner-up salary is 87000. Growth runner-up salary is 76000. Legal has one distinct salary and is excluded.
employees:
| emp_id | salary | dept |
|--------|--------|-------|
| 1 | 70000 | Ops |
| 2 | 70000 | Ops |
| 3 | 55000 | Audit |
| 4 | 55000 | Audit |[]Each department has only one distinct salary level, so no second-highest value exists.
employees:
| emp_id | salary | dept |
|--------|--------|-----------|
| 101 | 200000 | Security |
| 102 | 190000 | Security |
| 103 | 190000 | Security |
| 104 | 170000 | Security |
| 201 | 95000 | Support |
| 202 | 92000 | Support |
| 203 | 92000 | Support |
| 204 | 91000 | Support |[
{"emp_id":102,"dept":"Security"},
{"emp_id":103,"dept":"Security"},
{"emp_id":202,"dept":"Support"},
{"emp_id":203,"dept":"Support"}
]In both departments, the second-highest distinct salary appears multiple times, so all tied employees are returned.
Constraints