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

计算每天的新用户占比

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

select login_date as dt,
       count(distinct t1.uid) as total_user_num,
       concat(round(count(case when login_date=md then 1 else null end ) / count(distinct t1.uid) * 100 , 1), '%') as new_user_rate
from
(select * from  user_login_tb) t1
right join
(select uid, min(login_date) md from user_login_tb group by uid) t2
on t1.uid = t2.uid
group by login_date

全部评论

相关推荐

被加薪的哈里很优秀:应该继续招人,不会给你留岗位的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务