0

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

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

select created, regID
from registrations  

数据库中的日期格式如下:2012-11-01 00:00:00

4

4 回答 4

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)
于 2012-11-01T16:27:58.077 回答
0

您通常使用分组运算符:

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

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

于 2012-11-01T16:27:27.553 回答
0

试试这个:

SELECT created, count(regID) FROM registrations GROUP BY created ORDER BY created ASC
于 2012-11-01T16:27:28.247 回答
0
SELECT   DATE(DATE_REGISTERED) DATE, COUNT(*) totalRegistered
FROM     tableName
GROUP BY DATE
于 2012-11-01T16:28:24.907 回答