with t1 as( select *, min(date(in_time)) over(partition by uid) as first_in from tb_user_log # group by uid ), t2 as( select uid, date(in_time) as dt, first_in from t1 union select uid, date(out_time) as dt, first_in from t1 ), t3 as( select uid, dt, if(datediff(d...