我有以下mysql 5.5查询:
select count(original_url), original_url from page_views group by original_url order by count(original_url) desc;
但是也希望每天分组(比如2014-06-23),这样我就可以看到每个网址每天都有最多的page_view。它是一个rails应用程序,因此有一个created_at。我想的是:
select count(original_url), original_url, created_at from page_views group by original_url, created_at order by count(original_url) desc;
但是按小时选择和分组:min:sec我只想让它像YEAR-MONTH-DAY一样。我该怎么做?
答案 0 :(得分:1)
尝试日期功能:
select count(original_url), original_url, created_at from page_views group by original_url, DATE(created_at) order by count(original_url)