SQL166大厂面试真题

统计新用户的方法,判断用户最早登陆日期是否等于当前日期,是记为1。sum(if(new_user_time=time,1,0))

select time, count(distinct t1.uid)dau, round(sum(if(new_user_time=time,1,0))/count(distinct t1.uid) ,2)from

(

    select uid, date(in_time) as time from tb_user_log union

    select uid, date(out_time) as time from tb_user_log

)t1 join

(

    select uid, min(date(in_time))new_user_time from tb_user_log

    group by uid

)t2 using(uid)

group by time

order by time ASC

#笔试#
全部评论

相关推荐

不愿透露姓名的神秘牛友
05-01 13:13
ecece:这么明目张胆虚报就业率啊
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务