标签:ase font pre 功能 合并 number inter blog com
实现功能,对用户的访问做统计,最近7天的访问人数(1-7连续的),可以按照浏览器,或者其他条件进行分组,合并之后按时间排序
select group_concat(countValue order by sst.countKey),group_concat(countKey order by sst.countKey),brower from (
select DATE_FORMAT(mycreatedate,‘%m-%d‘) as countKey,ifnull(COUNT(pv.create_date), 0) as countValue ,pv.brower from (
SELECT curdate() as mycreatedate
union all
SELECT date_sub(curdate(), interval 1 day) as mycreatedate
union all
SELECT date_sub(curdate(), interval 2 day) as mycreatedate
union all
SELECT date_sub(curdate(), interval 3 day) as mycreatedate
union all
SELECT date_sub(curdate(), interval 4 day) as mycreatedate
union all
SELECT date_sub(curdate(), interval 5 day) as mycreatedate
union all
SELECT date_sub(curdate(), interval 6 day) as mycreatedate
) as total
LEFT JOIN base_log_event pv on DATE_FORMAT(pv.create_date,‘%Y-%m-%d‘)=total.mycreatedate
GROUP BY mycreatedate,pv.brower
) sst
group by sst.brower
注意,如果要对分组合并数据排序group_concat(ss order by ddd)这样写
标签:ase font pre 功能 合并 number inter blog com
原文地址:http://www.cnblogs.com/longsanshi/p/7804297.html