About the “Frequently Co-Purchased Product Pairs (Self-Join)” SQL Problem
Business Scenario
Market basket analysis uses self-joins on shopping cart items to uncover item pairs that customers consistently purchase together in the same order.
Expected Output & Criteria
Co-purchased product pairs appearing in at least 2 common orders.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMCREATE TABLE order_items (
order_id INT NOT NULL,
product_id INT NOT NULL,
PRIMARY KEY (order_id, product_id)
);Target SQL Clauses & Operators
Want more Joins practice?
Explore the full syllabus of 16 exercises and syntax guides.