了解每天注册的人数

时间:2012-11-01 16:23:24

标签: mysql

在mySQL中,我要做的是查询我的表并找出每天注册的人数。换句话说,我希望能够在一个月内产生以下输出:

1 January: 10 registrations
2 January: 150 registrations
3 January: 50  registrations

select created, regID
from registrations  

日期在DB:2012-11-01 00:00:00

中采用以下格式

4 个答案:

答案 0 :(得分:3)

要获取1月份每天的注册计数,请使用此select

select daymonth(registration_date), count(*)
from registrations
where registration_date >= '01/01/2012' and registration_date <= '01/31/2012'
group by daymonth(registration_date)

答案 1 :(得分:0)

您通常使用分组运算符:

SELECT COUNT(*) AS registrations, DATE(created) AS created_date GROUP BY created_date

如果created已经是DATE列,则不需要转换。

答案 2 :(得分:0)

试试这个:

SELECT created, count(regID) FROM registrations GROUP BY created ORDER BY created ASC

答案 3 :(得分:0)

SELECT   DATE(DATE_REGISTERED) DATE, COUNT(*) totalRegistered
FROM     tableName
GROUP BY DATE