Loading problem...
A merchandising platform stores catalog price updates as an event log.
Table: products
Data rules:
Task: Compute the effective price for every product on 2019-08-16.
Pricing semantics:
Output requirements:
Supported submission environments:
products:
| product_id | new_price | change_date |
|------------|-----------|-------------|
| 1 | 20 | 2019-08-14 |
| 2 | 50 | 2019-08-14 |
| 1 | 30 | 2019-08-15 |
| 1 | 35 | 2019-08-16 |
| 2 | 65 | 2019-08-17 |
| 3 | 20 | 2019-08-18 |[
{"product_id":1,"price":35},
{"product_id":2,"price":50},
{"product_id":3,"price":10}
]Product 1 uses its change on 2019-08-16. Product 2 ignores the 2019-08-17 update and keeps 50 from 2019-08-14. Product 3 has no update on or before 2019-08-16, so it falls back to baseline 10.
products:
| product_id | new_price | change_date |
|------------|-----------|-------------|
| 10 | 15 | 2019-08-20 |
| 10 | 18 | 2019-09-01 |
| 11 | 7 | 2019-08-01 |
| 11 | 9 | 2019-08-10 |
| 11 | 50 | 2019-08-17 |
| 12 | 25 | 2019-08-16 |[
{"product_id":10,"price":10},
{"product_id":11,"price":9},
{"product_id":12,"price":25}
]Product 10 has only future-dated changes and therefore remains at baseline 10. Product 11 picks the latest qualifying date before cutoff (2019-08-10). Product 12 has an exact-cutoff change, so price is 25.
products:
| product_id | new_price | change_date |
|------------|-----------|-------------|
| 101 | 80 | 2019-08-01 |
| 101 | 100 | 2019-08-16 |
| 102 | 22 | 2019-07-30 |
| 102 | 18 | 2019-08-15 |
| 103 | 40 | 2019-10-01 |[
{"product_id":101,"price":100},
{"product_id":102,"price":18},
{"product_id":103,"price":10}
]The query must choose the latest qualifying change per product, not the highest price. Product 103 has no qualifying change and defaults to 10.
Constraints