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

异常的邮件概率

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

题目要我们找到邮件异常的概率:

简单分析分为三个步骤

  1. 找到那天所有发送的邮件总数 sum 表一
  2. 找到那天所有发送失败的邮件总数 fal 表二
  3. sum/fal 就是发送失败的概率,所以我们要把两张表连接起来

找到那天所有发送的邮件总数 sum 表一

select date,count(*) as su from email
where receive_id!=2 
and send_id!=2
group by date

找到那天所有发送失败的邮件总数 fal 表二

select date,count(*) as fa from email
where receive_id!=2 
and send_id!=2
and type='no_completed'
group by date

用内连接将两张表连接起来, 概率:round(b.fa/a.su,3) p

select a.date ,round(b.fa/a.su,3) p 
from
(select date,count(*) as su from email
where receive_id!=2 
and send_id!=2
group by date) a
,
(select date,count(*) as fa from email
where receive_id!=2 
and send_id!=2
and type='no_completed'
group by date) b
where a.date=b.date;
全部评论

相关推荐

点赞 评论 收藏
分享
生命诚可贵:先不说内容怎么样 排版就已经太差劲了 第一眼看不到重点,第二眼已经没有再看的耐心了, 篇幅占的太满了 字体不要用灰色 观感不好 想重点突出的黑色加粗就可以了 多列要点 少些大段的句子 项目经历把项目用的技术要点列出来,光写个python plc什么的太宽泛了 自我评价也有点偏多
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务