Compute a rolling mean per product using SQL window functions.
This was asked in the SQL deep dive stage. The candidate used UNBOUNDED PRECEDING.
product_id, sale_date, sale_id, sale_amount, and rolling_mean.sale_id.product_id, sale_date, and sale_id.| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique identifier for the sale record |
| product_id | INT | Product identifier |
| product_name | VARCHAR(100) | Product name |
| sale_date | DATE | Date of the sale |
| sale_amount | NUMERIC(10,2) | Sale amount used in the rolling mean |