Buyers per Product
A customer may order the same product many times. Return each product once with buyers, the number of different customers who ordered it. Rows may come in any order.
Example 1
orders
| id | customer_id | product |
|---|---|---|
| 1 | 7 | pen |
| 2 | 7 | pen |
| 3 | 8 | pen |
| 4 | 7 | ink |
returns
| product | buyers |
|---|---|
| ink | 1 |
| pen | 2 |
Constraints
- Up to 16 orders
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.