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

异常的邮件概率

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

SELECT
    date,
    ROUND((nc / cnt), 3)
FROM
    (
        SELECT
            date,
            COUNT(CASE WHEN type = 'no_completed' THEN 1 END) nc,
            COUNT(*) cnt
        FROM
            email
        WHERE
            send_id <> 2
            AND receive_id <> 2
        GROUP BY
            date
    ) subquery




/*
select
    date,
        round(
        (
            select
                count(type) nc
            from
                email
            where
                send_id <> 2
                and receive_id <> 2
                and type = 'no_completed'
            group by
                date
        ) / (
            select
                count(type)
            from
                email
            where
                send_id <> 2
                and receive_id <> 2
            group by
                date
        ),3
        )#不加round保留的小数位数不对,加了round整段代码就有问题
from
    email
group by
    date
*/




    /*
    select count(type)
    from email
    where send_id<>2 and received_id<>2
    group by date
    
    
    
    select (type) nc
    from email
    where send_id<>2 and received_id<>2 and type='no_completed'
    group by date
    */

全部评论

相关推荐

点赞 评论 收藏
分享
白火同学:能。我当初应届沟通了1200,收简历50,面试10左右吧,加油投吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务