MySQL query to group by month

MySQL query to group by month

A simple query that may save some time. To count all data in a table and group by a month this year from a MySQL date time. i.e 2018-11-29 10:17:30. You can use the following query.
SELECT 
    MONTH(DATE COLUMN NAME HERE), count(*)
FROM
    YOUR TABLE
GROUP BY YEAR(DATE COLUMN NAME HERE) , MONTH(DATE COLUMN NAME HERE)
ORDER ID id DESC

Categories: Posts