List high-impact in-progress incidents with the assigned user and department
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
Return every incident with `impact = 'High'` and `status = 'In Progress'`, along with the assigned user (found through `assigned_user_id`) and that user's department name. Output columns: `incident_id`, `title`, `impact`, `status`, `user_id`, `full_name`, `email`, `department_id`, `department_name`. Order by `incident_id` ascending.
```hint Map the columns first
Write down which table each output column lives in, then follow the foreign keys from `incidents` to reach them.
```
### Input Table(s)
`incidents`
| column | type | meaning |
|---|---|---|
| incident_id | INTEGER | Incident identifier |
| title | VARCHAR | Short description of the incident |
| impact | VARCHAR | One of 'High', 'Medium', 'Low' |
| status | VARCHAR | One of 'Open', 'In Progress', 'Resolved', 'Closed' |
| assigned_user_id | INTEGER | User the incident is assigned to |
Primary key: `incident_id`. Foreign key: `assigned_user_id` references `users.user_id`.
`users`
| column | type | meaning |
|---|---|---|
| user_id | INTEGER | User identifier |
| full_name | VARCHAR | User's full name |
| email | VARCHAR | User's email address |
| department_id | INTEGER | Department the user belongs to |
Primary key: `user_id`. Foreign key: `department_id` references `departments.department_id`.
`departments`
| column | type | meaning |
|---|---|---|
| department_id | INTEGER | Department identifier |
| department_name | VARCHAR | Department name |
Primary key: `department_id`.
### Output Contract
| column | type | meaning |
|---|---|---|
| incident_id | INTEGER | The incident |
| title | VARCHAR | Incident title |
| impact | VARCHAR | Always 'High' in the result |
| status | VARCHAR | Always 'In Progress' in the result |
| user_id | INTEGER | The assigned user |
| full_name | VARCHAR | Assigned user's full name |
| email | VARCHAR | Assigned user's email |
| department_id | INTEGER | Assigned user's department |
| department_name | VARCHAR | Name of that department |
One row per matching incident, ordered by `incident_id` ascending. `incident_id` is unique, so the order is fully determined. No rounding applies.
### Example
`incidents`
| incident_id | title | impact | status | assigned_user_id |
|---|---|---|---|---|
| 1 | VPN gateway down | High | In Progress | 101 |
| 2 | Email delivery delays | Medium | In Progress | 102 |
| 3 | Payroll export failing | High | Open | 103 |
| 4 | Core switch packet loss | High | In Progress | 103 |
| 5 | Printer offline | Low | Resolved | 102 |
| 6 | SSO login errors | High | In Progress | 102 |
`users`
| user_id | full_name | email | department_id |
|---|---|---|---|
| 101 | Priya Shah | priya.shah@example.com | 1 |
| 102 | Tom Becker | tom.becker@example.com | 2 |
| 103 | Lena Ortiz | lena.ortiz@example.com | 1 |
`departments`
| department_id | department_name |
|---|---|
| 1 | Network Operations |
| 2 | Service Desk |
Expected output:
| incident_id | title | impact | status | user_id | full_name | email | department_id | department_name |
|---|---|---|---|---|---|---|---|---|
| 1 | VPN gateway down | High | In Progress | 101 | Priya Shah | priya.shah@example.com | 1 | Network Operations |
| 4 | Core switch packet loss | High | In Progress | 103 | Lena Ortiz | lena.ortiz@example.com | 1 | Network Operations |
| 6 | SSO login errors | High | In Progress | 102 | Tom Becker | tom.becker@example.com | 2 | Service Desk |
Incident 2 is in progress but has Medium impact, incident 3 is High but still Open, and incident 5 fails both filters. The three remaining incidents pick up their assignee's name, email and department.
### Constraints and Clarifications
- Row counts: `incidents` at most 10,000, `users` at most 1,000, `departments` at most 100.
- `impact` is one of 'High', 'Medium', 'Low' and `status` is one of 'Open', 'In Progress', 'Resolved', 'Closed', stored with exactly that spelling and casing.
- `assigned_user_id` is never NULL and always references a valid `users.user_id`.
- Every user belongs to one department: `users.department_id` is never NULL and always references a valid `departments.department_id`.
- Each incident has exactly one assignee, so no incident can appear twice in the result.
Overview: Write a SQL query that lists every high-impact incident still in progress, together with the assigned user's name, email and department. It tests multi-table joins along foreign keys, filtering on exact status values, and choosing between inner and left joins.