1.用 with as 建立两个两个临时表 a表为每个用户的活跃日期,b表为每个用户第一次的活跃日期 with a as (select uid,dt from ( SELECT uid,date(in_time) dt from tb_user_log UNION SELECT uid,date(out_time) dt from tb_user_log)t), b as (select uid,min(dt) from a group by uid) 2.使用sum if来确定每日新用户人数 select dt,COUNT(uid) as dau, round(sum(if((...