Count months when using AS

Hi Guys,

I have a COL named rDate which is a date type column.

SELECT DATE_FORMAT(`rDate`, '%M') AS DATE, COUNT(*) AS number FROM `cars` WHERE `rStatus` LIKE 'Total%'

What i am trying to do is count how many rows per month.

Could any one help me here so i can get a count for each month?

Add the GROUP BY

Cheers dude.

I’ve done the following now

SELECT MONTH(rDate) AS MONTH , COUNT(rDate) AS COUNT FROM cars WHERE rDate >= NOW() - INTERVAL 1 YEAR AND `rStatus` LIKE 'Total%' GROUP BY MONTH(rDate)

done some coding and got it working :slight_smile:

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.