Back to problems

Find most co‑purchased product pairs in SQL

SQL · Google · Medium

Write an ANSI SQL query that returns the five most common unordered product pairs bought together in the same order. A pair must consist of two different products. For each order, consider only the distinct products in that order: if the same product appears more than once in an order (for example, through multiple line items or a quantity greater than one), it should still be used only once when forming that order's pairs. Never pair a product with itself. Always place the…

Checking your access…