MySQL Query GROUP BY day / month / year

前端 未结 14 2334
野趣味
野趣味 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 06:58

    If you want to group by date in MySQL then use the code below:

     SELECT COUNT(id)
     FROM stats
     GROUP BY DAYOFMONTH(record_date)
    

    Hope this saves some time for the ones who are going to find this thread.

提交回复
热议问题