A financial analytics platform monitors transaction activity to support customer-level financial analysis. Write a PostgreSQL query that calculates a 7-day rolling average transaction amount for every transaction.
transactions to customers to include the customer name when available.customer_id.transaction_id, customer_id, customer_name, transaction_date, amount, rolling_7_day_avg.rolling_7_day_avg to 2 decimal places.customer_id ascending with NULLs last, then transaction_date ascending and transaction_id ascending.NULL for rolling_7_day_avg when no non-NULL amounts exist in the window.| Column | Type | Description |
|---|---|---|
| customer_idPK | INTEGER | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer's display name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| customer_id | INTEGER | Customer associated with the transaction |
| transaction_date | DATE | Calendar date of the transaction |
| amount | NUMERIC(12,2) | Transaction amount |