这是我的基本mysql查询,它用于计算每日用户数,所以我需要在2012-01-30至2012-02-19执行此操作,而不是手动修改它,有什么好方法吗?
select count(distinct user) FROM video WHERE date >= '2012-01-30 00:00' AND date <= '2012-01-30 23:55';
select count(distinct user) FROM video WHERE date >= '2012-01-31 00:00' AND date <= '2012-01-31 23:55';
...
答案 0 :(得分:2)
SELECT DATE(date) AS date, COUNT(DISTINCT user) FROM video
WHERE date >= '2012-01-30 00:00' AND date_pl <= '2012-02-19 00:00'
GROUP BY DATE(date)