-- show the expenses for each month, yields 30 records SELECT DATE_FORMAT(day, '%Y-%m') as month, FORMAT(SUM(amount), 2) as sum FROM tt_finances GROUP BY YEAR(day), MONTH(day) -- get the number of different months with expenses, should yield 1 record, but yields 30 records with counts between 1 and 34 SELECT COUNT(1) FROM tt_finances GROUP BY YEAR(day), MONTH(day)