with tb1 as( select distinct uid, date(in_time) dt, min(date(in_time))over(partition by uid) a from tb_user_log union select distinct uid, date(out_time) dt, min(date(in_time))over(partition by uid) a from tb_user_log ) select date(dt) b, count(uid), round(count(if(a=dt,1,null))/count(uid),2) from tb1 group by b order by b