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

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

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

  1. 求出用户活跃情况,用union去掉重复的记录 huoyue
  2. 求用户第一次登陆的时期 new_user
  3. 如果用户第一次登陆和活动时间一样就是新用户
with huoyue as (
    select 
        uid,
        date(in_time) as dt
    from tb_user_log
    union 
    select 
        uid,
        date(out_time) as dt
    from tb_user_log
    order by uid
),
new_user as (
    select 
        uid,
        min(dt) first_login
    from huoyue
    group by 1
)
select 
    dt,
    count(*) as dau,
    round(sum(if(first_login=dt,1,0))/count(*),2) as uv_new_ratio
from huoyue left join new_user using (uid)
group by dt
order by dt
全部评论

相关推荐

06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
程序员饺子:正常 我沟通了200多个 15个要简历 面试2个 全投的成都的小厂。很多看我是27直接不会了😅
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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