Skip to main content
All Problems
hard0% acceptance

Market Basket: Frequently Co-Purchased Products

Find pairs of products that are frequently bought together in the same order. For each pair, count how many orders contain both products. Only include pairs appearing in at least 2 orders. Show product_a name, product_b name, and co_purchase_count. Avoid duplicate pairs (A,B and B,A). Sort by count descending.

Schema

🔑idINT
nameTEXT
🔗category_idINT
priceREAL
costREAL
stock_quantityINT
created_atTIMESTAMP
postgresql

Run your query to see results

Press Ctrl + Enter to execute