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

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

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

with zb2 as (with zb as (select uid,in_time dt
from tb_user_log
union   /**/ 
select uid,out_time
from tb_user_log)
select uid,date_format(dt,"%Y-%m-%d") dt,row_number() over(partition by uid order by dt) new_uid /*排序,1为新用户首次登录时间*/
from zb)
select dt,count(distinct uid) dau,round(sum(if(new_uid=1,1,0))/count(distinct uid),2) uv_new_ratio /*1为新用户其他为0*/
from zb2
group by dt
order by dt

全部评论

相关推荐

02-04 17:01
南昌大学 Java
牛客96763241...:拿插件直接投就完了,这玩意看运气的
点赞 评论 收藏
分享
03-03 23:42
复旦大学 Java
tongx_:闹呢,这找不到其他人还活不活
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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