with t1 as (
select uid,substr(in_time,1,10) as dt,
(unix_timestamp(out_time) - unix_timestamp(in_time)) as toltime
from tb_user_log
where substr(in_time,1,7) = '2021-11' and artical_id != 0
),
t2 as (
select dt,uid,sum(toltime) as tol1
from t1
group by dt,uid
),
t3 as (
select dt,count(distinct uid) as renshu,sum(tol1) as tol2 from t2 group by dt
)
select dt, round(tol2/renshu,1) as avg_viiew_len_sec from t3 order by avg_viiew_len_sec

京公网安备 11010502036488号