0

我有以下声明:

select count(*), FirstAdded from db.table where date(FirstAdded) between '2013-07-01' and '2013-07-10' group by Firstadded order by count(*)

当我执行它时,每次将一行添加到表中时,它都会返回数据。

1 | 2013-07-03 15:22:14
1 | 2013-07-03 15:23:14
1 | 2013-07-03 15:22:42
1 | 2013-07-03 15:45:29

我想将此归结为每天添加的行数(没有 m:s 时间,仅用于一整天)。例如

345  | 2013-07-03 
7482 | 2013-07-04
1237 | 2013-07-05 

这可能吗?

4

1 回答 1

3

这是一个group by查询:

select date(FirstAdded), count(*)
from db.table
group by date(FirstAdded);

该函数date()将日期时间值转换为日期值,这似乎是您想要的。

您的完整查询将是:

select count(*), date(FirstAdded)
from db.table
where date(FirstAdded) between '2013-07-01' and '2013-07-10'
group by date(Firstadded)
order by count(*)
于 2013-07-25T14:06:48.927 回答