Find open incidents with high impact and high urgency
Company: ServiceNow
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
The `incidents` table logs IT service incidents. Find all incidents with `impact` High, `urgency` High, and `status` New or In Progress. Return `incident_id`, `title`, `impact`, `urgency`, `status`, `created_at`, ordered by `created_at` ascending, then `incident_id` ascending.
### Input Table(s)
`incidents`
| Column | Type | Meaning |
| --- | --- | --- |
| incident_id | INT | Incident identifier (primary key) |
| title | VARCHAR(255) | Short description of the incident, not null |
| impact | VARCHAR(50) | One of 'High', 'Medium', 'Low', not null |
| urgency | VARCHAR(50) | One of 'High', 'Medium', 'Low', not null |
| status | VARCHAR(50) | One of 'New', 'In Progress', 'Resolved', 'Closed', not null |
| created_at | TIMESTAMP | When the incident was opened, not null |
Primary key: `incident_id`.
### Output Contract
- Columns, in this order: `incident_id`, `title`, `impact`, `urgency`, `status`, `created_at`.
- One row per matching incident.
- Sort by `created_at` ascending, then `incident_id` ascending.
- No rounding or formatting; return the stored values.
### Example
`incidents`
| incident_id | title | impact | urgency | status | created_at |
| --- | --- | --- | --- | --- | --- |
| 1 | VPN gateway down | High | High | New | 2024-03-01 09:15:00 |
| 2 | Email delivery delays | High | Medium | New | 2024-03-01 08:00:00 |
| 3 | Payroll portal errors | High | High | In Progress | 2024-03-01 07:30:00 |
| 4 | Printer offline | Low | Low | New | 2024-03-02 10:00:00 |
| 5 | Database failover | High | High | Resolved | 2024-02-28 22:00:00 |
| 6 | SSO login failures | High | High | New | 2024-03-01 09:15:00 |
Expected result:
| incident_id | title | impact | urgency | status | created_at |
| --- | --- | --- | --- | --- | --- |
| 3 | Payroll portal errors | High | High | In Progress | 2024-03-01 07:30:00 |
| 1 | VPN gateway down | High | High | New | 2024-03-01 09:15:00 |
| 6 | SSO login failures | High | High | New | 2024-03-01 09:15:00 |
Incident 2 fails on urgency, incident 4 fails on impact and urgency, and incident 5 is already resolved. Incidents 1 and 6 were opened at the same moment, so `incident_id` decides their order.
### Constraints and Clarifications
- The table has at most 10,000 rows, and `incident_id` is unique.
- Every column is NOT NULL, so no NULL handling is needed.
- `impact`, `urgency` and `status` hold exactly the values listed above, with that capitalization and spacing.
- Several incidents can share a `created_at` value; the secondary sort on `incident_id` makes the order unique.
```hint Combining conditions
If you express the two statuses with OR, check how it binds next to the AND conditions.
```
Overview: Write a SQL query that returns every incident with high impact, high urgency and a status of New or In Progress, sorted by creation time with a tie-breaker. It tests multi-condition WHERE filters, matching a column against a list of values, and deterministic ordering.