Write a SQL query using window functions to calculate each customer's 7-day rolling average purchase amount.
Assume the source table is purchases. Include each purchase in the result, and calculate the average across that purchase date and the six preceding calendar days. NULL purchase amounts should not contribute to the average.
customer_id, purchase_date, purchase_amount, and rolling_7_day_avgcustomer_id, purchase_date, and purchase_id| Column | Type | Description |
|---|---|---|
| purchase_idPK | INT | Unique identifier for the purchase |
| customer_id | INT | Identifier of the customer who made the purchase |
| purchase_date | TIMESTAMP | Timestamp when the purchase occurred |
| purchase_amount | DECIMAL(10,2) | Purchase amount, which may be NULL |