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

异常的邮件概率

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

select q1.date date, round(count1/count,3) p
from
(select a.date date, count(a.id) count
from (select *
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
)) a ##查找只有正常用户发送给正常用户的邮件信息
group by a.date) q1 ##按日期分组查找对应日期的邮件总数

left join 

(select a.date date, case when count(a.id) is null then 0# case count(a.id) when null then 0
                     else count(a.id)
                     end as count1
from (select *
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
)) a ##复制粘贴上方的a表,查找只有正常用户发送给正常用户的邮件信息
where a.type = 'no_completed'
group by a.date) q2 ##按日期分组查找对应日期的失败的邮件总数

on q1.date = q2.date;

全部评论

相关推荐

02-15 22:29
门头沟学院 Java
点赞 评论 收藏
分享
给🐭🐭个面试机会吧:我boss直聘天天有家教跟我打招呼😓
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务