SELECT
CAST(MONTH(DocumentDate) AS VARCHAR(2)) + '-' + CAST(YEAR(DocumentDate) AS VARCHAR(4)) AS DocumentDate,
SUM(QTY) AS qty
FROM [FAToolService].[dbo].[ConsolidatedGPRawDataDetail]
GROUP BY CAST(MONTH(DocumentDate) AS VARCHAR(2)) + '-' + CAST(YEAR(DocumentDate) AS VARCHAR(4))
DocumentDate 是年-月-日 的Datetime 格式。
取每個月的數量總合....