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

异常的邮件概率

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
    */

全部评论

相关推荐

06-03 15:32
点赞 评论 收藏
分享
04-11 15:34
已编辑
华中科技大学 网络安全
疯犬丨哈士奇:意思就是:我们还有其他更优秀的人在等回复,如果他们不要这个机会就会来找你
点赞 评论 收藏
分享
05-29 20:34
门头沟学院 C++
KarlAllen_直通春招版:得做好直接春招的准备。学历差的话,一是面试要求会比学历好的严格不少,二是就算面试通过了也会被排序。总之暑期和秋招对于学历差的就是及其不友好
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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