SELECT goods.purchase_date, SUM(price), MONTH(purchase_date) AS mont
FROM goods
GROUP BY mont
SELECT MONTH(purchase_date) AS mont, SUM(price) AS goods_sum
FROM goods
GROUP BY MONTH(purchase_date)
SELECT YEAR(purchase_date) AS goods_year,
MONTH(purchase_date) AS goods_month,
SUM(price) AS goods_sum
FROM goods
GROUP BY YEAR(purchase_date), MONTH(purchase_date)
ORDER BY 1, 2