题解 | 计算每天的新用户占比

计算每天的新用户占比

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

select
  login_date as dt,
  count(distinct uid) as total_user_num,
  concat(
    round(
      count(distinct case when rn = 1 then uid end)
      / count(distinct uid) * 100,
      1
    ),
    '%'
  ) as new_user_rate
from (
  select
    uid,
    login_date,
    row_number() over (partition by uid order by login_date) as rn
  from user_login_tb
) c
group by login_date
order by login_date;

全部评论

相关推荐

02-28 01:18
已编辑
南昌大学 后端工程师
后测速成辅导一两个月...:把开源经历放个人项目上边应该更好,就像大部分人都把实习经历放个人项目上边
点赞 评论 收藏
分享
肖先生~:大一点得到公司面试更能学到点东西
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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