I have a table to store website visiter count bellow
id date ip
-----------------------------
1 1-1-2012 195.165.1.2
2 1-1-2012 195.165.1.3
3 12-2-2012 195.165.1.8
and i want a mysql query for get count of each month of current year
seeing your DATE column, i assumed that you save dates as VARCHAR
SELECT MONTHNAME(STR_TO_DATE(date, '%c-%e-%Y')) `monthName`, COUNT(*) totalCount
FROM tableName
WHERE YEAR(STR_TO_DATE(date, '%c-%e-%Y')) = YEAR(CURDATE())
GROUP BY MONTHNAME(STR_TO_DATE(date, '%c-%e-%Y'))
OTHER SOURCEs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With