通过从完整日期提取月份来汇总数据

时间:2014-07-02 14:45:30

标签: sql function date time

我想按月计算所有人数。现在它正在分组。

Select 
    TRUNC(ed.COVERAGE_START_DATE),
    Count(Distinct Egpa.Person_Id)

1 个答案:

答案 0 :(得分:0)

尝试:

SELECT Month, Count(Person)
  FROM Table
 GROUP BY month

OR

SELECT DATEPART(Month, YourDate) Month
  FROM yourtable
 GROUP BY DATEPART(Month, YourDate)