Loyal category buyers

MediumAmazonjoinscount distincthaving· 20 XP

Amazon's personalisation team wants to spot shoppers who keep coming back to the same category, for "your favourites" emails.

Find each customer and category where the customer bought from that category in at least 3 different orders (any status except cancelled).

Expected output

  • Any row order

Example of the shape (made-up values):

customer_id category orders
51 Books 3

Hints, the later steps and the answer come with Pro.

Write your query here. Ctrl + Enter submits.