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

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

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

select dt,count(*) as dau, round(sum(new_in = dt)/count(*),2) as uv_new_ratio  
from
(select uid,date(in_time) as dt
from tb_user_log
union 
select uid,date(out_time) as dt
from tb_user_log)a
join(select uid,min(date(in_time))as new_in from tb_user_log group by uid)b using (uid)
group by dt
order by dt

算逻辑表达式时不要习惯性用count

从0开始的SQL之旅 文章被收录于专栏

从0开始的SQL之旅

全部评论

相关推荐

点赞 评论 收藏
分享
每晚夜里独自颤抖:这个在牛客不是老熟人了吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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