How would you use a window function to calculate a rolling average of order values for Zomato users?
Use the completed orders only. Return one row per order, and ignore rows where the order timestamp is NULL.
user_id, order_id, order_timestamp, order_value, rolling_avg_order_valueuser_id, then order_timestamp, then order_id| Column | Type | Description |
|---|---|---|
| user_id | INT | Zomato user identifier |
| order_idPK | INT | Unique order identifier |
| order_timestamp | TIMESTAMP | Timestamp when the order was placed |
| order_value | NUMERIC(10,2) | Final value of the order |
| order_status | VARCHAR(20) | Order status such as completed, cancelled, or pending |