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

异常的邮件概率

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

代码量最多但是最无脑的写法……

选出所有正常用户发送的邮件

select a.date,round(b.bad/a.num,3) as p
from
(select date,count(id) num from email
where send_id in (select id from user where is_blacklist=0)
and receive_id in (select id from user where is_blacklist=0)
group by date) a
join
(select date,count(id) bad from email
where send_id in (select id from user where is_blacklist=0)
and receive_id in (select id from user where is_blacklist=0)
and type = 'no_completed'
group by date) b
on a.date = b.date
order by a.date
#(select id from user where is_blacklist=0)查所有正常用户
#(select date,count(id) num from email
where send_id in (select id from user where is_blacklist=0)
and receive_id in (select id from user where is_blacklist=0)
group by date) 查所有正常用户发的邮件
#查所有正常用户发送失败的邮件
#除一下即可哈哈哈

全部评论

相关推荐

09-24 17:30
门头沟学院 Java
叁六玖:上个班还要,七连面,唐三成神都只有九考呢,这公司怕不是要招个半神
我的秋招日记
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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