High-Balance Loyalty Members
Problem
A retailer runs a points-based loyalty program. `Members` lists each member's card and name (names are unique). `PointEvents` records every change to a card's balance: positive when points are earned, negative when redeemed. Every card starts at 0.
`Members`:
- `card` (int) — unique card number
- `member_name` (varchar)
`PointEvents`:
- `event_id` (int) — unique id
- `card` (int) — card affected
- `points` (int) — points added (positive) or redeemed (negative)
- `happened_on` (date)
Report the name and current balance of every member whose balance exceeds **10000** points. Balance is the sum of all point events for that card. Rows may be in any order.
Tables
Example rows — the live problem includes the full dataset.
| card | member_name |
|---|---|
| 700001 | Priya |
| 700002 | Marco |
| 700003 | Lena |
| event_id | card | points | happened_on |
|---|---|---|---|
| 1 | 700001 | 7000 | 2021-08-01 |
| 2 | 700001 | 7000 | 2021-09-01 |
| 3 | 700001 | -3000 | 2021-09-02 |
Expected output
Your answer should return 1 row with the columns member_name, balance.
Starter code (SQL)
SELECT *
FROM Members;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock