with tmp as( select uid,date(in_time) dt from tb_user_log where artical_id = 0 and sign_in = 1 and date(in_time) between '2021-07-07' and '2021-10-31' order by dt) select uid,date_format(dt,'%Y%m') as month, sum(case when nums in (3,10,17,24,31) then 3 when nums in (7,14,21,28) then 7 ...