Products Bought Together
Hard
Joins
Return all pairs of products that appear in the same order, with the number of orders in which they appear together. Output the pair with the smaller product_id first, ordered by count descending then product ids.
Table schema
OrderItems(order_id INT, product_id INT)Sample data
order_id | product_id
1 | 10
1 | 20
2 | 10
2 | 20
2 | 30
3 | 20
3 | 30
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.