TASK #223 · Hard · SantanderRolling 7-Day Charges
Your brief
Santander's anti-fraud team monitors how much money leaves an account over 7 days.
The rolling sum of an account on date D is the total of its charges
(tx_type = 'cargo') with tx_date from D − 6 days to D
inclusive, i.e. over 7 calendar days.
Write a query that calculates the rolling sum for each account and each date on which that account had a charge, and returns the rows where it is strictly greater than 1000 €: account_id, tx_date and rolling_7d. Each (account, date) pair must appear once.
Write a query that calculates the rolling sum for each account and each date on which that account had a charge, and returns the rows where it is strictly greater than 1000 €: account_id, tx_date and rolling_7d. Each (account, date) pair must appear once.
Ctrl / ⌘ + ↵
Result
Write a query and run it to see the results.
Schema
customerscustomer_id, full_name, cityaccountsaccount_id, customer_id, account_type, balance, overdraft_limittransactionstransaction_id, account_id, tx_date, tx_type, amount, description