Given a table of account balances, write a query to calculate the daily rolling average balance for each user.
For this exercise, calculate each user's average balance for the current date and the preceding two calendar days. If multiple balance records exist on one date, first determine that user's daily average. Ignore NULL balances.
user_id, balance_date, daily_average_balance, and rolling_average_balance.user_id and balance_date.| Column | Type | Description |
|---|---|---|
| balance_idPK | INT | Unique identifier for the balance record |
| user_id | INT | Identifier of the account owner |
| balance_date | DATE | Date on which the balance was recorded |
| balance | NUMERIC(12,2) | Account balance recorded for the user |