Write a SQL query using window functions to calculate a rolling average of commodity prices over the last 30 days.
Calculate the average separately for each commodity. Treat the 30-day period as inclusive of the observation date, and allow NULL prices to be ignored by the average.
commodity, price_date, price, and rolling_avg_30d.commodity, then price_date ascending.| Column | Type | Description |
|---|---|---|
| price_idPK | INT | Unique price observation identifier |
| commodity | VARCHAR(50) | Commodity name |
| price_date | DATE | Date of the observed commodity price |
| price | NUMERIC(10,2) | Observed commodity price |