MySQL Query GROUP BY day / month / year

前端 未结 14 2362
野趣味
野趣味 2020-11-22 06:37

Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a TIMESTAMP field, like

14条回答
  •  误落风尘
    2020-11-22 07:05

    The following query worked for me in Oracle Database 12c Release 12.1.0.1.0

    SELECT COUNT(*)
    FROM stats
    GROUP BY 
    extract(MONTH FROM TIMESTAMP),
    extract(MONTH FROM TIMESTAMP),
    extract(YEAR  FROM TIMESTAMP);
    

提交回复
热议问题