The fraud detection team wants to compare each transaction to the previous one on the same account. For account_id = 1, return transaction_date, amount, the previous transaction amount (prev_amount using LAG), and the difference. Order by date.
Schema
🔑idINT
🔗account_idINT
transaction_dateTEXT
typeTEXT
amountREAL
balance_afterREAL
descriptionTEXT
reference_numberTEXT
postgresql
Run your query to see results
Press Ctrl + Enter to execute