更新时间:2022-02-19 23:12:59
使用 MySQL 非常简单 MONTH() 函数以及GROUP BY caluse.
It's very easy you can use MySQL MONTH() function for this along with GROUP BY caluse.
SELECT SUM(SI.quantity),MONTH(SI.date_added)
FROM sale_items SI
JOIN sales S
ON S.id=SI.sale_id
WHERE S.status = 'completed'
GROUP BY MONTH(SI.date_added);