練習11 --查詢選修"張三"老師所授課程的學生中,成績最高的學生信息及其成績


-- 查詢選修"張三"老師所授課程的學生中,成績最高的學生信息及其成績

select
    t5.*,
    t4.s_score as MAX_score,
    t4.c_id,
    t6.c_name
from
    (score t4,
    student t5)
right join course t6 on
    t6.c_id = t4.c_id
where
    t4.s_score = (
    select
        max(t3.s_score)
    from
        teacher t1,
        course t2,
        score t3
    where
        t1.t_name = '張三'
        and t1.t_id = t2.t_id
        and t2.c_id = t3.c_id)
    and t4.s_id = t5.s_id
select
    a.*,
    b.s_score,
    b.c_id,
    c.c_name
from
    student a
left join score b on
    a.s_id = b.s_id
left join course c on
    b.c_id = c.c_id
where
    b.c_id =(
        select c_id
    from
        course c,
        teacher d
    where
        c.t_id = d.t_id
        and d.t_name = '張三')
    and b.s_score in (
        select max(s_score)
    from
        score
    where
        c_id = '02')

 

-- 2019/05/05


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM