题解 | #每天的日活数及新用户占比#

每天的日活数及新用户占比

http://www.nowcoder.com/practice/dbbc9b03794a48f6b34f1131b1a903eb

with a as(
select uid,dt,dense_rank() over(partition by uid order by dt) as rank1 from
(select uid,date(in_time) dt from tb_user_log
UNION
select uid,date(out_time) dt from tb_user_log t1
where date(out_time) not in(select date(in_time) from tb_user_log t2 where t1.uid=t2.uid)
)a1
    )
select dt,count(uid) as dau,round(sum(rank1=1)/count(uid),2) as uv_new_ratio
from a
group by dt
全部评论

相关推荐

12-27 22:49
门头沟学院 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务