All tasks

Sum of the Last 3 Transactions of a Client

Intermediate

Typical task from Tinkoff/Sber. **Condition:** For each client, find the date of the last transaction and the sum of the last 3 transactions. **Table:** bank_transactions (from_account_id, to_account_id, amount, transaction_date, ...) **Requirements:** 1. Determine the last transaction for each client 2. Sum the last 3 transactions (by date) 3. Output account_id, last_transaction_date, last_3_sum **Hint:** ROW_NUMBER + SUM with ROWS BETWEEN.

Category
Window Functions
Estimated time
~20 min
Databases
PostgreSQLGreenplum
Tags
TinkoffInterviewROW_NUMBERWindow FrameBankingоконные функции

Sign in to solve

Start Solving