tally / count mysql每天的结果 [英] tally/count mysql results per day
本文介绍了tally / count mysql每天的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个名为 signups
的mysql表,并具有以下值:
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
有没有办法在mysql中这样做,或者我需要使用另一种语言,如PHP来计算总和?
Is there a way to do this in mysql, or do I need to involve another language like PHP to calculate totals?
任何想法都赞赏, p>
Any ideas are appreciated, thanks
推荐答案
SELECT DATE(Signup_Date) AS `Date`
, COUNT(*) AS Signups
FROM `signups`
GROUP BY
DATE(Signup_Date)
会为您提供您所期待的内容。
will give you exactly what you're after.
这篇关于tally / count mysql每天的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文