Find the bugs: customer events before an order

For order 2, find all events belonging to the same customer that occurred before or at the exact moment the order was placed. Include events whose timestamps match the order timestamp exactly. The tables are linked by iv_events.user_id = iv_orders.customer_id. Find the line that causes the query to include events it should exclude.

Find the errorsDatesMiddleAnalystData EngineerBackendQA
Input data · iv_events
iduser_idevent_typecreated_at
11login2026-01-31 23:59:00
21login2026-01-31 23:59:00
31view2026-02-01 00:00:00
42login2026-02-01 08:00:00
52view2026-02-01 08:05:00
62view2026-02-01 08:05:00
73login2026-02-02 10:00:00
8NULLview2026-02-03 11:00:00
91purchase2026-02-03 12:00:00
102logout2026-02-28 23:59:59
Input data · iv_orders
idcustomer_idstatuscreated_attotal
11paid2026-01-15 10:00:00100.00
21paid2026-01-31 23:59:0050.00
32paid2026-02-01 00:00:00200.00
42cancelled2026-02-10 12:30:0075.50
53paid2026-02-28 23:59:5930.00
6NULLpaid2026-03-01 00:00:0060.00
75new2026-03-05 09:15:00120.00
81paid2026-03-31 18:00:0080.00
SELECT e.id AS event_id,
       e.created_at AS event_at
FROM iv_orders o
JOIN iv_events e
  ON e.user_id = o.customer_id
WHERE o.id = 2
  AND e.created_at >= o.created_at
ORDER BY e.id