题解 | #SQL类别高难度试卷得分的截断平均值#

SQL类别高难度试卷得分的截断平均值

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

with
    l1 as (
        select
            exam_id,
            tag,
            difficulty
        from
            examination_info
        where
            tag = 'SQL'
            and difficulty = 'hard'
        group by
            exam_id,
            tag,
            difficulty
    ),
    l2 as (
        select
            *
        from
            exam_record
        where
            submit_time is not null
    )

select
    tag,
    difficulty,
    round(avg(score) ,1)as clip_avg_score
from
    (
        select
            tag,
            difficulty,
            score,
            row_number() over (
                partition by
                    tag
                order by
                    score desc
            ) as rank_1,
            row_number() over (
                partition by
                    tag
                order by
                    score asc
            ) as rank_2
        from
            l1 join l2  on l1.exam_id = l2.exam_id
    ) a
where
    rank_1 > 1
    and rank_2 > 1
group by
    tag,
    difficulty

全部评论

相关推荐

有趣的牛油果开挂了:最近这个阶段收到些杂七杂八的短信是真的烦
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务