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

异常的邮件概率

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

# 首先 正常用户筛选,剔除掉黑名单
# send_id not in (select id from user where is_blacklist = 1)
# receive_id  not in n (select id from user where is_blacklist = 1)
# 接着,正常用户发送邮件数# 然后,正常用户发送失败邮件数
select a.date, format(b.lo_num / a.total_num,3)  as p
from (select date,count(send_id) as total_num 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 )a
join 
(select date,count(send_id) as lo_num from email 
where type = 'no_completed' 
and 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)b
on a.date = b.date
group by a.date

全部评论

相关推荐

02-26 18:25
已编辑
南京大学 算法工程师
点赞 评论 收藏
分享
01-23 19:12
门头沟学院 Java
榨出爱国基因:你还差 0.1% 就拿到校招礼盒,快叫朋友给你砍一刀吧
投递拼多多集团-PDD等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务