Fill chart gaps with zeros
A daily-stock chart must not have «holes»: even if nothing happened in the event log on a given day, the point should be present and equal to zero — otherwise the chart gets gaps and reads incorrectly.
Generate a calendar of days from January 1 to January 15, 2024 inclusive (15 days total — both bounds included), match it against the warehouse events for product_id = 1, and for every day compute the total delta, substituting zero where there were no events. Show the day and the daily delta, sorted by day.
Expected output sample
This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.
| d | delta |
|---|---|
| 2024-01-01 | 10 |
| 2024-01-02 | 0 |
| 2024-01-03 | 0 |
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in