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

#笔试#
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 17:00
点赞 评论 收藏
分享
在喝茶的牛油很喜欢吃...:今天oc了
点赞 评论 收藏
分享
每晚夜里独自颤抖:这个在牛客不是老熟人了吗
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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