# 先计算每一天的活跃用户人数 with t1 as ( select uid, date_format(in_time, '%Y-%m-%d') as dt from tb_user_log union select uid, date_format(out_time, '%Y-%m-%d') as dt from tb_user_log ), t2 as ( select dt, count(uid) as total_people from t1 group by dt ), t3 as ( # 每一个用户的首次登录时间 select uid, min(dt) as dt from t1...