MySQL 利用时间(秒分时日月年)分组统计
1.统计 七天 前 人数
select count(*) from your_table where last_login_time> date_sub(date(now()), interval 7 day);
date_add
2.按天累计人数
select DATE_FORMAT(last_login_time, '%Y-%m-%d') as dd, count(*) as '每日' from your_table group by dd order by dd desc;
3.按月统计
select DATE_FORMAT(last_login_time, '%Y-%m') as dd, count(*) as '每月' from your_table group by dd order by dd desc;
本文来自博客园,作者:迷茫的小白,转载请注明原文链接:https://www.cnblogs.com/cloudHui/p/16023039.html

浙公网安备 33010602011771号