How would you use SQL window functions to calculate rolling 7-day sales for each restaurant location?
Use the provided restaurant and sales data. Calculate results only for locations with recorded sales, and treat the rolling period as the current sale date plus the six preceding calendar days.
restaurant_id, location_name, sale_date, daily_sales, and rolling_7_day_sales.restaurant_id, then sale_date ascending.| Column | Type | Description |
|---|---|---|
| restaurant_idPK | INT | Unique identifier for a restaurant location |
| brand | VARCHAR(50) | Yum! Brands restaurant brand |
| location_name | VARCHAR(100) | Display name for the restaurant location |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique identifier for a sales transaction |
| restaurant_id | INT | Restaurant location associated with the sale |
| sale_date | DATE | Calendar date of the sale |
| sales_amount | DECIMAL(12,2) | Sales amount recorded for the transaction |