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

异常的邮件概率

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;


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

全部评论

相关推荐

2025-11-26 09:37
山西大学 测试工程师
我要娶个什么名:学长你电脑闹鬼了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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