题解 | #异常的邮件概率#

异常的邮件概率

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

方法一:子查询



# # 正常用户的id: 1,3,4    不正常用户的id为  2 ;则排除不正常用户的id
# send_id not in (select id from user where is_blacklist=1)
# and
# receive_id not in  (select id from user where is_blacklist=1)
# # 让你统计正常用户发送给正常用户邮件失败的概率    : 正常用户:发送失败的/发送总数
# round(sum(if(type="no_completed",1,0))/count(type),3)
# # 最后SQL语句为
select date ,round(sum(if(type="no_completed",1,0))/count(type),3) as p from email
where send_id not in (select id from user where is_blacklist=1)
and
receive_id not in  (select id from user where is_blacklist=1)
group by date
order by date;


方法二:评论区的连表查询

全部评论

相关推荐

06-23 11:28
门头沟学院 Java
牛客91966197...:也有可能是点拒绝的时候自动弹的话术
点赞 评论 收藏
分享
头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-09 12:11
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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