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

异常的邮件概率

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;


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

全部评论

相关推荐

复制粘贴骂ai!
聪明的加菲猫又在摸鱼:我写论文也是这样,不断教育ai
点赞 评论 收藏
分享
我就是0offer糕手:北大不乱杀
点赞 评论 收藏
分享
不吃牛肉的选手在刷面试经:首先,你数过吗?其次,他知道吗?最后,你说了他信吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务