- 本题主要考察子连接问题,通过筛选出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`;