Hide Trial Tickets for Paying Members
Problem
A help desk stores support tickets in `tickets` with columns `(ticket_id, member_id, tier)`. `tier` is 0 for a 'paid' ticket and 1 for a 'trial' ticket. `ticket_id` is unique.
Report tickets using these rules:
- If a member has at least one paid ticket (tier = 0), do NOT report any of that member's trial tickets (tier = 1).
- Otherwise, report all of the member's tickets.
Return `ticket_id`, `member_id`, `tier` in any order.
Tables
Example rows — the live problem includes the full dataset.
| ticket_id | member_id | tier |
|---|---|---|
| 1 | 100 | 0 |
| 2 | 100 | 1 |
| 3 | 101 | 1 |
Expected output
Your answer should return 4 rows with the columns ticket_id, member_id, tier.
Starter code (SQL)
SELECT *
FROM tickets;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