The treasury team wants a unified view of all cash inflows: deposit transactions and loan payments. Use UNION ALL to combine deposit transactions (with source = 'deposit') and loan payments (with source = 'loan_payment'). Return source, the date (transaction_date or payment_date), and amount. Sort by date descending. Limit to 50.
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