Your inventory team wants to identify products that have appeared in more than one order. Using the order_items table, return a single value popular_products — the count of distinct product IDs that appear in at least two different orders.
order_items
| column | type |
|---|---|
| id | INTEGER |
| order_id | INTEGER |
| product_id | INTEGER |
| quantity | INTEGER |
| id | order_id | product_id | quantity |
|---|---|---|---|
| 1 | 1 | 10 | 2 |
| 2 | 1 | 20 | 1 |
| 3 | 2 | 10 | 3 |
| 4 | 3 | 30 | 1 |
| 5 | 2 | 20 | 2 |
| popular_products |
|---|
| 2 |
Product 10 appears in orders 1 and 2. Product 20 appears in orders 1 and 2. Product 30 only appears in order 3. So two products meet the threshold.