题解 | #2021年11月每天的人均浏览文章时长#
2021年11月每天的人均浏览文章时长
http://www.nowcoder.com/practice/8e33da493a704d3da15432e4a0b61bb3
1.求每一天 浏览文章时长的总和
2.求每一天 人数
select dt, round(sum(view_len_sec)/count(distinct uid), 1) as avg_view_len_sec from( select uid,DATE(in_time) as dt,TIMESTAMPDIFF(SECOND,in_time,out_time) as view_len_sec from tb_user_log where artical_id != 0 AND DATE_FORMAT(in_time, "%Y%m") = "202111" )s group by dt order by avg_view_len_sec ASC