题解 | #异常的邮件概率#
异常的邮件概率
https://www.nowcoder.com/practice/d6dd656483b545159d3aa89b4c26004e
select date, round(count(case when type = 'no_completed' then 1 end)/count(type),3) as p from email left join user u1 on send_id = u1.id left join user u2 on receive_id = u2.id where u1.is_blacklist = 0 and u2.is_blacklist = 0 group by 1 order by 1 asc
很简单,先找到发送和接受都不是黑名单的用户的邮件记录,再统计no_completed的记录数量除以全部,再round 3