我有一张如下表:
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 中做到这一点?
尝试
SELECT DATE(`day`) as `DAY`, COUNT(*) totalCount
FROM TABLE
WHERE date BETWEEN date() AND TARDATE
GROUP BY DATE(`day`)
ORDER BY day DESC
试试这个
SELECT DATE(day), COUNT(*) as total_no FROM TABLE WHERE date ( BETWEEN date() AND TARDATE ) GROUP BY DATE(day) ORDER BY day DESC