Rank accounts by balance volatility. Volatility is measured as the difference between the maximum and minimum balance_after values across all transactions for that account divided by the average balance_after. Return account_id, min_balance, max_balance, avg_balance (rounded to 2), volatility (rounded to 4), and volatility_rank using RANK(). Order by volatility_rank ascending.
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