Users with net revenue of at least 100
The finance director wants to see users whose net revenue is at least 100 — i.e. the sum of purchases minus refunds per user lands at 100 or higher.
For each user compute the net revenue (purchase events count positively, refund events count negatively; refund amounts are already stored with a negative sign in the data) and keep only those whose net revenue is at least 100. Return the user id and their net revenue, ordered by revenue descending.
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.
| net | user_id |
|---|---|
| 400.00 | 3 |
| 300.00 | 1 |
| 100.00 | 4 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in