答案 0 :(得分:1)
CREATE TABLE #TEMP_A
(
CREATEDYESTERDAY INT,
CREATEDTHISWEEK INT,
CREATEDTHISYEAR INT,
CALCDATE DATE
)
INSERT INTO #TEMP_A
VALUES(0,0,26226,'05/18/2018')
INSERT INTO #TEMP_A
VALUES(71,1647,7402,'05/18/2018')
INSERT INTO #TEMP_A
VALUES(21,60,1931,'05/18/2018')
INSERT INTO #TEMP_A
VALUES(21,60,1931,'04/18/2018')
SELECT SUM(CREATEDYESTERDAY) AS [SUM],DATENAME(MONTH,CALCDATE) AS [MONTH] FROM #TEMP_A GROUP BY DATENAME(MONTH,CALCDATE)