AnalystPath

Support Ticket Resolution Histogram

SQLEasyJunior level~15 min

Problem

A help desk wants a histogram of how long tickets took to resolve, grouped into four time buckets (minutes):

- `under 30` : less than 30 minutes
- `30 to under 60` : at least 30 and less than 60 minutes
- `60 to under 90` : at least 60 and less than 90 minutes
- `90 or more` : 90 minutes or more

Table: `tickets`

| Column | Type |
|-------------|------|
| ticket_id | int |
| minutes | int |

`ticket_id` is the primary key. `minutes` is how long the ticket took to resolve.

Write a query that returns one row per bucket with columns `bucket` and `tickets`, where `tickets` is the number of tickets in that bucket. **Every bucket must appear even if its count is 0.** Return the rows in any order.

Tables

Example rows — the live problem includes the full dataset.

tickets
ticket_idminutes
120
225
328

Expected output

Your answer should return 4 rows with the columns bucket, tickets.

Starter code (SQL)

SELECT *
FROM tickets;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions