练习8--查询两门及其以上不及格课程的同学的学号,姓名及其平均成绩


-- 查询两门及其以上不及格课程的同学的学号,姓名及其平均成绩 

select
    t1.s_id,
    t1.s_name,
    t3.avg_score
from
    student t1,
    (
        select t2.s_id,
        round(avg(s_score)) as avg_score
    from
        (
        select
            *
        from
            score
        where
            s_score < '60') t2
    group by
        t2.s_id
    having
        count(t2.s_id) >= 2) t3
where
    t1.s_id = t3.s_id
select
    a.s_id,
    a.s_name,
    round(avg(b.s_score))
from
    student a
left join score b on
    a.s_id = b.s_id
where
    a.s_id in(
    select
        s_id
    from
        score
    where
        s_score<60
    group by
        s_id
    having
        count(1)>= 2)
group by
    a.s_id,
    a.s_name

 

--2019/4/25


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM