是不是想要这样的结果,sql语句如下
select a.时间段,count(1) 个数 from (
select concat(date_format(t.time,'%Y-%m-'),
case
when DAY(t.time) BETWEEN 1 and 5 then '1-5日'
when DAY(t.time) BETWEEN 6 and 10 then '6-10日'
when DAY(t.time) BETWEEN 11 and 15 then '11-15日'
when DAY(t.time) BETWEEN 16 and 20 then '16-20日'
when DAY(t.time) BETWEEN 21 and 25 then '21-25日'
when DAY(t.time) BETWEEN 26 and 31 then '26-31日'
else 9 end) 时间段
from fine_last_login t) a group by a.时间段;