练习9--检索"01"课程分数小于60,按分数降序排列的学生信息 | 按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩


-- 检索"01"课程分数小于60,按分数降序排列的学生信息

select
    t2.*
from
    score t1,
    student t2
where
    t2.s_id = t1.s_id
    and t1.s_score < '60'
    and t1.c_id = '01'
order by
    t1.s_score;

 

-- 按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩

select
    a.*,
    b.c_id,
    b.s_score
from
    student a,
    score b
where
    a.s_id = b.s_id
    and b.c_id = '01'
    and b.s_score<60
order by
    b.s_score desc;
select
    a.s_id,
    (
        select s_score
    from
        score
    where
        s_id = a.s_id
        and c_id = '01') as 语文,
    (
        select s_score
    from
        score
    where
        s_id = a.s_id
        and c_id = '02') as 数学,
    (
        select s_score
    from
        score
    where
        s_id = a.s_id
        and c_id = '03') as 英语,
    round(avg(a.s_score), 1)
from
    score a
group by
    a.s_id
order by
    avg(a.s_score) desc;

 

--2019/04/28


免责声明!

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



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