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


with t1 as(
    select *,
    min(date(in_time)) over(partition by uid) as first_in
    from tb_user_log
    # group by uid
),
t2 as(
    select uid, date(in_time) as dt, first_in from t1
    union
    select uid, date(out_time) as dt, first_in from t1
),
t3 as(
    select uid, dt,
    if(datediff(dt,first_in)=0,1,0) as is_new
    from t2
)
select dt,
count(uid) as dau,
round(sum(is_new)/count(uid),2) as uv_new_ratio
from t3
group by dt
order by dt asc









全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 15:58
投个小米提前批试试水,先投一个岗位看看形势,不行就再沉淀一下投第二个岗位,莫辜负
Java抽象带篮子:我嘞个骚刚,已经开始研发6g了吗
投递小米集团等公司7个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-09 13:05
TMD找工作本来就烦,这东西什么素质啊😡
Beeee0927:hr是超雄了,不过也是有道理的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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