Write a SQL query to calculate week-over-week sales change for each 7-Eleven store using a date table and sales table.
Use the calendar weeks represented in the date table and include weeks with no sales as zero. Return the first available week for each store with NULL comparison values.
store_id, week_start, weekly_sales, prior_week_sales, wow_change, and wow_change_pct.wow_change_pct should be NULL when prior-week sales are NULL or zero. Order by store_id, then week_start.| Column | Type | Description |
|---|---|---|
| calendar_datePK | DATE | Calendar date |
| week_start | DATE | Start date of the reporting week |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| store_id | VARCHAR(10) | 7-Eleven store identifier |
| sale_date | DATE | Date on which the sale occurred |
| sales_amount | NUMERIC(10,2) | Sales amount for the transaction |