select dt,round(sum(td)/count(distinct uid),1) avg_viiew_len_sec from (select uid,artical_id,substring(in_time,1,10) dt,timestampdiff(second,in_time,out_time) td from tb_user_log where artical_id <>0 and substring(in_time,1,7)='2021-11') t group by dt order by avg_viiew_len_sec