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


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









全部评论

相关推荐

牛客38347925...:9,2学生暑期实习失利开始投小厂,给这群人整自信了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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