Users With Paid Orders
Marketing is building a list of users who have at least one order with status = 'paid'. Rewrite the report without the nested list check and return unique user id values sorted by id.
Original query
SELECT u.id FROM users u WHERE u.id IN (SELECT user_id FROM orders WHERE status = 'paid') ORDER BY u.id
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| id |
|---|
| 1 |
| 2 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in