I have the following MySQL syntax, it returns the max transaction_id for each user. It displays the correct max transaction_id for each user. However, it does not display the correct balance. Because for example it will display the correct max transaction_id but will display the balance from the lower transaction_id.
SELECT MAX(transaction_id) as transaction_id, username, balance FROM user_transactions GROUP BY username
Any ideas how to fix this?