SELECT YEAR(transaction_date) AS Year, MONTH(transaction_date) AS Month, 
       SUM(amount) AS Total_Amount
FROM transactions
GROUP BY LAST_DAY(transaction_date);