DB/MSSQL

SQL 월별 통계 쿼리

벨포트조던 2020. 8. 13.
반응형

SELECT

  DATEPART(MONTH, REG_DT) AS MONTH

 ,COUNT(*) AS VAL

FROM    TBL

WHERE   REG_DT >='2016-01-01' 

AND     REG_DT <= '2016-12-31'

GROUP BY DATEPART(MONTH, REG_DT)



http://stackoverflow.com/questions/14565788/how-to-group-by-month-from-date-field-using-sql


반응형

댓글