Amazon recommendation algorithms power the 'Frequently Bought Together' widget on product detail pages. Write a SQL query to identify all distinct pairs of products that appear together in the same order at least 3 times. To prevent duplicates and self-pairs: return each pair only once with `product_1 < product_2`, and never pair a product with itself. Return `product_1`, `product_2`, and `pair_count`. Order the results by `pair_count DESC`, then `product_1 ASC`, and `product_2 ASC`.
Loading…
Try solving the question with the schema explorer and hints first. When ready, reveal the verified canonical query and step-by-step logic breakdown.
Ask questions, share alternate queries, and explore solutions
Your recent query executions and answer checks
This will insert the verified MySQL solution into your editor so you can study how each clause transforms the table.