How do you use moving window functions in SQL?
Write a PostgreSQL query that calculates each seller's daily completed order amount and its three-row moving average. The moving window includes the current date and up to the two preceding seller dates. Use the provided tables and include only sellers with completed orders.
seller_id, seller_name, order_date, daily_amount, moving_averageseller_id, then order_date ascending| Column | Type | Description |
|---|---|---|
| seller_idPK | INT | Unique seller identifier |
| seller_name | VARCHAR(100) | Seller display name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| seller_id | INT | Seller associated with the order |
| order_date | DATE | Date the order was placed |
| order_amount | NUMERIC(10,2) | Order amount |
| status | VARCHAR(20) | Order processing status |