SQL 如何抽取中一HKAT Eng, Chi and Math 的成績?

本文由 Canyon 在 2019-08-21 發表於 "WebSAMS 討論區" 討論區

標籤:
  1. 10109629

    Canyon
    Expand Collapse

    文章:
    81
    讚:
    0
  2. 58685934

    edb-ds
    Expand Collapse

    文章:
    22
    讚:
    0
    請參考以下SQL:

    select
    a.classcode,
    a.classno,
    a.enname,
    a.chname,
    (case when b.subjectcode=1 then 'Chi'
    when b.subjectcode=2 then 'Eng'
    when b.subjectcode=3 then 'Math'
    else null end) 'Subject',
    b.totalscore 'Score',
    d.engname 'Componant',
    c.sectionscore 'Comp Score'
    from vw_stu_lateststudent a
    join tb_hka_scores b
    on a.suid=b.suid and a.stuid=b.stuid and a.schyear=b.schyear and b.testlevel='S1A'
    left outer join tb_hka_sectionscores c
    on a.suid=c.suid and a.stuid=c.stuid and a.schyear=c.schyear and b.subjectcode=c.subjectcode and b.testlevel=c.testlevel
    left outer join tb_hka_section d
    on a.suid=d.suid and a.schyear=d.schyear and c.subjectcode=d.subjectcode and c.sectioncode=d.sectioncode and b.testlevel=d.testlevel
    where a.schyear=? and a.classlvl =?
    order by a.classcode, a.classno, a.enname
     
  3. 10109629

    Canyon
    Expand Collapse

    文章:
    81
    讚:
    0
    Thank you