101
0/304
Loading content...
A commerce analytics team tracks purchase events and product pricing in two tables.
Sales columns:
Product columns:
Task:
Output requirements:
Supported submission environments:
Sales:
| sale_id | product_id | user_id | quantity |
|---------|------------|---------|----------|
| 1 | 1 | 101 | 10 |
| 2 | 2 | 101 | 1 |
| 3 | 3 | 102 | 3 |
| 4 | 3 | 102 | 2 |
| 5 | 2 | 103 | 3 |
Product:
| product_id | price |
|------------|-------|
| 1 | 10 |
| 2 | 25 |
| 3 | 15 |[
{"user_id":101,"spending":125},
{"user_id":102,"spending":75},
{"user_id":103,"spending":75}
]User 101 spends 1010 + 125 = 125. Users 102 and 103 both spend 75, so user_id ascending breaks the tie.
Sales:
| sale_id | product_id | user_id | quantity |
|---------|------------|---------|----------|
| 11 | 10 | 7 | 2 |
| 12 | 20 | 7 | 1 |
| 13 | 10 | 8 | 3 |
| 14 | 30 | 8 | 2 |
Product:
| product_id | price |
|------------|-------|
| 10 | 40 |
| 20 | 10 |
| 30 | 5 |
| 40 | 99 |[
{"user_id":8,"spending":130},
{"user_id":7,"spending":90}
]Only product_ids present in Sales contribute. Product 40 is unused and does not affect totals.
Sales:
[]
Product:
| product_id | price |
|------------|-------|
| 1 | 100 |
| 2 | 200 |[]With no purchase rows, no user has spending to report.
Constraints