logo

Oracle NextGen

score

SQL Challenge

Challenge #14 – Product Recommendation Pairs

Challenge Overview
Find pairs of products that are frequently bought together (in the same order). Show pairs that appear in at least 2 orders.

Requirements

  • Return columns: product1_name, product2_name, times_bought_together.
  • Self-join order_items to find product pairs in same orders.
  • Avoid duplicate pairs (e.g., A-B and B-A should count as one).
  • Filter for pairs appearing in 2 or more orders.
  • Order by times_bought_together descending.
Sample Dataset
Preview the schema and seeded rows you can query against.

products

Product catalog.

Columns
NameTypeNotes
product_idINTPrimary key
product_nameVARCHARProduct name
Sample Rows
product_idproduct_name
1Laptop
2Mouse
3Keyboard
4Monitor

order_items

Items in each order.

Columns
NameTypeNotes
order_idINTOrder ID
product_idINTProduct ID
Sample Rows
order_idproduct_id
11
12
21
22
23
31
33
42
44
51
52
SQL Playground
Loading editor…

Result Preview

Awaiting Run

Run your query to see the dataset preview.