IDFC FIRST Bank wants to monitor short-term customer transaction patterns. Write a PostgreSQL query that calculates the rolling 7-day average transaction amount for each active customer using a window function.
transaction_status = 'POSTED'.transaction_amount is NULL.customer_id, transaction_date, and transaction_id.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer's name |
| is_active | BOOLEAN | Whether the customer has an active banking relationship |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| customer_id | INT | Customer who made the transaction |
| transaction_date | DATE | Transaction posting date |
| transaction_amount | NUMERIC(12,2) | Transaction amount |
| transaction_status | VARCHAR(20) | Transaction processing status |