with td as ( select id,uid,date(in_time) as indate,date(out_time) as outdate from tb_user_log ), tnew as ( select t.indate,count(t.uid) as nb_new from td t where not exists ( select 1 from td tback where tback.uid=t.uid and tback.indate < t.indate ) group by t.indate ) select t.indate, round(sum(...