GROUP BY month on DATETIME field

后端 未结 5 1252
我寻月下人不归
我寻月下人不归 2021-01-02 08:49

I have the following query in mysql:

SELECT title, 
       added_on 
FROM   title 

The results looks like this:

Somos Tão J         


        
5条回答
  •  一整个雨季
    2021-01-02 09:17

    The best bet is to group it by YEAR and then by MONTH. See below

    SELECT Count(*), Date(timestamp) FROM title GROUP BY YEAR(timestamp), Month(timestamp) 
    

提交回复
热议问题