Skip to content
SQLSimplified
Data AnalystQuestion 35 of 57

Market Basket Analysis (Self Join)

Problem

The store manager wants to know which products are frequently ordered together. To start, write a self-join query that finds pairs of different products that share the same order_id in the orders table. Output order_id and the product IDs as product_a and product_b. (Note: simulate with pseudo tables).

Database Schema

This problem acts as a scratchpad. You will write your own DDL/DML or conceptual queries, so there is no predefined schema.

Try It

Loading playground environment...

Hint

Solution