AnalystPath

High-Balance Loyalty Members

SQLEasyJunior level~15 min

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.

Members
cardmember_name
700001Priya
700002Marco
700003Lena
PointEvents
event_idcardpointshappened_on
170000170002021-08-01
270000170002021-09-01
3700001-30002021-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

Related SQL questions