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

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

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

with t1 as(
    select uid,date(in_time) dt
    from tb_user_log
    union
    select uid,date(out_time) dt
    from tb_user_log
),
t2 as(
    select uid,min(dt) min_dt from t1
    group by uid
)
select dt,count(*) dau,round(sum(if(min_dt=dt,1,0))/count(*),2)uv_new
from t1
left join t2
on t1.uid=t2.uid
group by dt

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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