fulfil_events (event_id, order_id, status, event_at) is a warehouse's order-status feed. The feed re-sends an order's current status from time to time, so the same status can appear on several rows in a row. Rows are also ingested late, so event_id doesn't follow time: put each order's rows in event_at order, breaking ties by event_id.
An order is on hold from a row whose status is 'on_hold' while the order's previous row was not 'on_hold' (or there was no previous row), until the next row with any other status. A hold with no such row is still open: count it up to 2024-06-10 12:00:00.
Operations flag an order when a single hold lasted more than 24 hours, or when its holds add up to more than 36 hours. Return the flagged orders with:
- •
holds — how many separate holds the order had - •
total_hold_hours and longest_hold_hours — rounded to 1 decimal place
Columns: order_id, holds, total_hold_hours, longest_hold_hours. Sort by order_id.