Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tally/count mysql results per day

Lets say I have a mysql table called 'signups' with the following values:

Name            Signup Date
dog            2008-05-14 18:53:30
cat            2008-05-14 12:13:20
mouse          2008-05-14 08:51:32
giraffe        2008-05-15 22:13:31
Moose          2008-05-16 13:20:30
monkey         2008-05-16 08:51:32
mongoose       2008-05-16 22:13:31
fish           2008-05-16 13:00:30

I want to generate a report for how many animals signed up for each DAY (I don't care about the time of day). So the end result of what I'm looking for from the above example table is:

Date              Signups
2008-05-14         3
2008-05-15         1
2008-05-16         4

Is there a way to do this in mysql, or do I need to involve another language like PHP to calculate totals?

Any ideas are appreciated, thanks

like image 743
themerlinproject Avatar asked Mar 29 '11 17:03

themerlinproject


1 Answers

SELECT  DATE(Signup_Date) AS `Date`
        , COUNT(*) AS Signups 
FROM    `signups` 
GROUP BY 
        DATE(Signup_Date)

will give you exactly what you're after.

like image 145
Glen Solsberry Avatar answered Nov 11 '22 04:11

Glen Solsberry