mysql query to get count of each month compare to last year from timestamp column code example Example: mysql group by day GROUP BY DATE_FORMAT(record_date, '%Y%m')