Exercise 02

The Duplicate Trap

The upstream message broker guarantees at-least-once delivery. Engineering told you this in passing; nobody wrote it down. Some rows in event_log are the same logical event delivered twice — same delivery_id, but slightly different received_at because the broker retried.

Table: event_log(delivery_id, user_id, event_type, received_at).

Return one row per user with their `user_id` and the number of **distinct** events they generated. Legitimate repeat events (same user, same event type, different occurrences) should still count separately.

Your query