Last transaction per account: debit USD
Level: MiddleTopic: Top-N per group100 XP
Instructions
For each account with the type 'debit' and the currency 'USD' find its latest transaction among transactions with tx_time strictly before September 1, 2025. If an account has several such transactions with the same tx_time, take the transaction with the larger id. Accounts without such transactions are not in the result. Columns: account_id, tx_id (the transaction id), tx_time, amount, category. Row order does not matter.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Exactly oneZero or oneZero or more
Table relationships
- N:1Many-to-one
accounts.→client_id clients.id - N:1Many-to-one
transactions.→account_id accounts.id
Table data
PostgreSQL
Select a table in the diagram or list to view its rows.