The number of MySQL and the number of days per day

I have the following structure

ID    DATE(DATETIME)         TID
1     2012-04-01 23:23:23    8882

I try to count the number of rows and group them every day of the month that matches TID = 8882

thank

+5
source share
4 answers

You can group using the DAY function :

SELECT DAY(Date), COUNT(*)
FROM table
WHERE TID = 8882
GROUP BY DAY(Date)
+9
source

I’m not sure exactly what you mean by the day of the month — do you want to group February 1 from March 1? Or do you mean only the date? Assuming the latter, how about this:

SELECT DATE(date) as d,count(ID) from TABLENAME where TID=8882 GROUP by d;
+6
source

:

SELECT DAY(date) AS `DAY`,  COUNT(1) AS `COUNT` FROM
table1 
    WHERE TID = 8882
GROUP BY DAY(date)

MySQL Query GROUP BY //

+2

:

SELECT COUNT(id), DAY(dat), MONTH(dat), YEAR(dat) 
FROM table
WHERE TID=8882
GROUP BY YEAR(dat), MONTH(dat), DAY(dat);
0

All Articles