customers_who_bought_all_products.sql
DuckDB 1.5
Not run yet
+ 5 hidden
Input
basket_line line_id customer_id item_id 1 7 1 2 8 1 3 7 2 4 9 2 5 8 3 6 9 3 7 7 3 8 9 1 9 9 3 catalog_item item_id item_name 1 kettle 2 teapot 3 mug
Expected
[{"customer_id": 7}, {"customer_id": 9}]The catalogue has three items. Customer 7 bought the kettle, the teapot and the mug; customer 9 bought all three too, the mug twice. Customer 8 never bought the teapot, so 7 and 9 are the result.