mysql如何统计最近一周的数据
发布日期:2019-08-12 浏览次数:1195 关键词:mysql统计
select a.click_date,ifnull(b.count,0) as count_reg from ( SELECT curdate() as click_date union all SELECT date_sub(curdate(), interval 1 day) as click_date union all SELECT date_sub(curdate(), interval 2 day) as click_date union all SELECT date_sub(curdate(), interval 3 day) as click_date union all SELECT date_sub(curdate(), interval 4 day) as click_date union all SELECT date_sub(curdate(), interval 5 day) as click_date union all SELECT date_sub(curdate(), interval 6 day) as click_date ) a left join ( select date(FROM_UNIXTIME(reg_time)) as datetime, count(*) as count from member group by date(FROM_UNIXTIME(reg_time)) ) b on a.click_date = b.datetime;
在企业网站建设中,如何用mysql统计最近7天数据?如上图,试试,
希望以上对你有所帮助。
- GO 欣赏案例
- 查看经典案例