mediumonline store · Q5
anti-joinNOT EXISTSNULL traps

Laptops but no accessories

Marketing wants to send an accessories coupon to people who bought a laptop but never bought an accessory.

Return every customer who has a completed order containing a product in the Laptops category, and who has never had a completed order containing a product in the Accessories category.

Each customer should appear once, no matter how many laptops they bought.

output columns
customer_idname

uses , , ,

ctrl + enter to run on the sample data · ctrl + shift + enter to submit

run your query to see the output here. Submit checks it against the sample data, hidden test cases, random data and a large dataset.