Exercise 05

The Orphan Join

Sales pulls last quarter's revenue numbers and the totals don't reconcile with finance — finance is ~$100 higher. You suspect a referential-integrity problem: the users table got rebuilt at some point and an old user_id no longer exists, but its orders are still in orders.

Tables: users(id, name, signed_up_at), orders(id, user_id, amount_cents, ordered_at).

Return `user_id` and `revenue_cents` (gross — ignore refunds for this exercise) for **every user_id that has at least one order**, including orphan user_ids no longer in `users`. Order by `user_id`.

Your query