Support Tickets Grouped Into 4-Hour Shifts
Problem
Table: `hourly_tickets`
| Column Name | Type |
|---|---|
| hour_of_day | int |
| ticket_count | int |
`hour_of_day` is the primary key, an integer from 1 upward. Each row is how many support tickets arrived in that hour.
Group the hours into 4-hour shifts: hours 1-4 are shift 1, hours 5-8 are shift 2, hours 9-12 are shift 3, and so on. Report each `shift_no` and its `total_tickets`. Order by `shift_no`.
Tables
Example rows — the live problem includes the full dataset.
| hour_of_day | ticket_count |
|---|---|
| 1 | 5 |
| 2 | 3 |
| 4 | 2 |
Expected output
Your answer should return 3 rows with the columns shift_no, total_tickets.
Starter code (SQL)
SELECT *
FROM hourly_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