A classic time series task. **Condition:** For each account, calculate the 7-day moving average of transaction amounts. **Table:** bank_transactions (from_account_id, amount, transaction_date, ...) **Requirements:** 1. For each day and account — average over the last 7 days (including the current one) 2. If fewer than 7 days — calculate based on available data 3. Round to 2 decimal places **Hint:** AVG() OVER (PARTITION BY account ORDER BY date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
Sign in to solve
Start Solving