题解 | #找到每个人的任务#
异常的邮件概率
http://www.nowcoder.com/practice/d6dd656483b545159d3aa89b4c26004e
- 本题主要考察子连接问题,通过筛选出send_id 和 receive_id 对用的 is_blacklist都不为1;
- 然后是对失败邮件的统计占比,注意保留的小数点位
select `date`, round(sum(if(type="completed", 0, 1))/count(send_id), 3) 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`;