runtime
34 / 88

task IN / EXISTS / NOT EXISTS · medium

Loyal shoppers who never needed a refund

Return the id and name of shoppers who have at least two delivered orders and have never received a refund on any of their orders.

what to return

Columns
idname in this order
Rows
2 rows · any order
Watch for
A refund on any order — delivered or not — disqualifies the shopper.
Skill
Combine “at least N” with “never” conditions. Refresher: Filter groups with HAVING →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result2 rows · any order
idname
5Esi Mensah
6Farah Aziz

all 2 rows

data you can query

Sample rows from each table. Each column shows its type underneath; → marks a link to another table.

shoppers5 columns · 17 rows
idinteger · keynametextemailtextregiontextsignup_datetext
1Ana Ruizana@harbor.testWest2025-01-03
2Ben Okaforben@harbor.testEast2025-01-05
3Chloe Parkchloe@harbor.testWest2025-01-09
4Dmitri Volkovdmitri@harbor.testNorth2025-01-14
5Esi MensahNULLSouth2025-01-20

showing 5 of 17 rows

sales_orders5 columns · 33 rows
idinteger · keyshopper_idinteger → shoppersorder_datetextstatustextdelivered_datetext
10112025-01-04delivered2025-01-08
10222025-01-06delivered2025-01-07
10312025-01-15delivered2025-01-20
10432025-01-18cancelledNULL
10542025-01-22delivered2025-01-31

showing 5 of 33 rows

order_refunds4 columns · 6 rows
idinteger · keyorder_idintegerrefunded_attextamountreal
11032025-01-2515
21062025-02-0674
31112025-02-2559
41112025-02-2645
51222025-03-2010

showing 5 of 6 rows

solution.sql
 

Hints and the answer are always available. Using them counts the question as solved with help.