Your question is Running Average for Last 5 Days. 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.
EXL Service Philippines analysts need a daily sales metric for an operations reporting dashboard. Write a PostgreSQL query that calculates the running average of sales for the current day and the four preceding calendar days.
reporting_calendar, including dates with no transactions.daily_amount, treating missing transaction days as zero and ignoring NULL transaction amounts.five_day_running_avg using the current date and up to four preceding calendar dates.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| transaction_date | DATE | Date on which the transaction occurred |
| amount | NUMERIC(12,2) | Sales amount for the transaction |
| Column | Type | Description |
|---|---|---|
| calendar_datePK | DATE | Calendar date required in the report |