-1

我有一张如下表:

  block int not null
  day datetime not null
  user int

我想要

  select day, count(*) 
  from TABLE 
  where date between date() and TARDATE 
  group by day 
  order by day desc

问题是,我只想按日期分组,而不是按时间分组。

我将如何在 MySQL/php 中做到这一点?

4

2 回答 2

3

尝试

SELECT DATE(`day`) as `DAY`, COUNT(*) totalCount
FROM   TABLE 
WHERE  date BETWEEN date() AND TARDATE 
GROUP BY DATE(`day`)
ORDER BY day DESC
于 2012-09-28T03:34:42.200 回答
0

试试这个

SELECT DATE(day), COUNT(*) as total_no FROM TABLE WHERE  date ( BETWEEN date() AND TARDATE ) GROUP BY DATE(day) ORDER BY day DESC
于 2012-09-28T04:59:03.710 回答