select a.new_day '新增日期' ,count(a.qq_no) '新增用户数' ,count(case when a.new_day = date_sub(b.read_day, 1) then a.qq_no else null end)/count(a.qq_no) 'd1阅读留存率' ,count(case when a.new_day = date_sub(b.read_day, 3) then a.qq_no else null end)/count(a.qq_no) 'd3阅读留存率' ,count(case when a.new_day = date_sub(b.read_day, 15) then a.qq_no else null end)/count(a.qq_no) 'd15阅读留存率' ,count(case when a.new_day = date_sub(b.read_day, 30) then a.qq_no else null end)/count(a.qq_no) 'd30阅读留存率' from (select new_day, qq_no from t1 where new_day <= '2019-08-10' and new_day >= '2019-08-01' group by new_day, qq_no )a left join (select read_day, qq_no from t2 group by read_day, qq_no )b on a.qq_no = b.qq_no group by a.new_day