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

计算每天的新用户占比

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

#新简化写法

select 
t.login_date as dt,
count(distinct uid) as total_user_num,
concat(
ifnull(
round(
(
count(distinct case when t.m=1 then uid end)/count(distinct uid)
)*100,1),0),"%") as new_user_rate
from(
select
uid,
login_date,
row_number()over(partition by uid order by login_date) as m 
from user_login_tb
group by uid,login_date
) as t 
group by t.login_date
order by t.login_date

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 13:05
点赞 评论 收藏
分享
05-19 15:21
已编辑
门头沟学院 Java
白火同学:你才沟通了200,说实话,北上广深杭这里面你连一座城市的互联网公司都没投满呢,更别说还有各种准一线二线城市了。等你沟通突破了三位数,还没结果再考虑转行的事吧。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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