Your question is SQL: 7-Day Rolling Average. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
CVS Health operations leaders need a daily view of sales trends across CVS Pharmacy locations. Write a PostgreSQL query that calculates each store's 7-day rolling average of daily sales for January 1 through January 7, 2024.
| Column | Type | Description |
|---|---|---|
| store_idPK | INTEGER | Unique CVS store identifier |
| store_code | VARCHAR(10) | CVS store code |
| store_name | VARCHAR(100) | Store location name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| store_id | INTEGER | References stores.store_id |
| sale_date | DATE | Date of the transaction |
| sale_amount | NUMERIC(12,2) | Sales amount for the transaction |