學生成績 抽取成績和負責老師

本文由 HUI CHUN KIT 在 2023-11-14 發表於 "WebSAMS 討論區" 討論區

  1. 59753528

    HUI CHUN KIT
    Expand Collapse

    文章:
    4
    讚:
    0
    請問可以用 SQL 抽取以下資料嗎?

    REGNO, CLASS, CLASSNO, SUBJCODE, SUBJCOMCODE, PRINTSEQ, RAW SCORE, SUBJECT GRADE, FORM RANK, CLASS / GROUP RANK, Teacher STAFF CODE

    where schyear = XXXX and TIMESEQ = YYYY

    XXXX 是 school year , e.g. 2023
    YYYY 是 assessment time sequence e.g. 1103


    如果有多個一個老師任教,可否 Teacher STAFF CODE 係 comma separated list of STAFF CODE
     
    #1 HUI CHUN KIT, 2023-11-14
  2. 58521906

    edb-catherinewschan
    Expand Collapse

    文章:
    310
    讚:
    0
    你好

    請參考以下的SQL


    select
    a.regno,
    a.classcode '班別',
    a.classno '班號',
    a.chname '姓名',
    a.enname 'Name',
    b.timeseq '考績',
    c.en_des 'Subject',
    c.ch_des '科目',
    b.sysscore '成績',
    b.sysgradeconvcompcode '成績GRADE',
    d2.ch_des '分卷科目',
    d1.sysscore '分卷成績',
    d1.sysgradeconvcompcode '分卷成績GRADE',
    b.OMCLASS '科目班名次',
    b.OMCLASslvl '科目級名次',
    (case when e.CROSSSUBJGRP is null then (select list(h.name_chi, ', ') from wsadmin.TB_SCH_CLSSUBJTCHR g
    join wsadmin.VW_ASR_STAFF h on a.SUID = h.SUID and g.STAFFCODE = h.STAFFCODE
    where a.SUID = g.SUID and a.SCHYEAR = g.SCHYEAR and a.SCHLVL = g.SCHLEVEL and a.schsess = g.SCHSESSION and a.classlvl = g.CLASSLEVEL and a.CLASSCODE = g.CLASSCODE and b.SUBJCODE = g.SUBJCODE and b.MOI = g.MOI) else (select list(j.name_chi, ', ')
    from wsadmin.TB_SCH_DSGSUBJTCHR i
    join wsadmin.VW_ASR_STAFF j on a.SUID = j.SUID and i.STAFFCODE = j.STAFFCODE
    where a.SUID = i.SUID and a.SCHYEAR = i.SCHYEAR and a.SCHLVL = i.SCHLEVEL and a.schsess = i.SCHSESSION and e.CROSSSUBJCODE=i.DIVSUBJCODE and e.CROSSSUBJGRP=i.SUBJGRPCODE) end) '任教老師',

    (case when e.CROSSSUBJGRP is null then (select list(h.STAFFCODE, ', ')
    from wsadmin.TB_SCH_CLSSUBJTCHR g
    join wsadmin.VW_ASR_STAFF h on a.SUID = h.SUID and g.STAFFCODE = h.STAFFCODE where a.SUID = g.SUID and a.SCHYEAR = g.SCHYEAR and a.SCHLVL = g.SCHLEVEL and a.schsess = g.SCHSESSION and a.classlvl = g.CLASSLEVEL and a.CLASSCODE = g.CLASSCODE and b.SUBJCODE = g.SUBJCODE and b.MOI = g.MOI) else (select list(j.name_eng, ', ')
    from wsadmin.TB_SCH_DSGSUBJTCHR i
    join wsadmin.VW_ASR_STAFF j on a.SUID = j.SUID and i.STAFFCODE = j.STAFFCODE where a.SUID = i.SUID and a.SCHYEAR = i.SCHYEAR and a.SCHLVL = i.SCHLEVEL and a.schsess = i.SCHSESSION and e.CROSSSUBJCODE=i.DIVSUBJCODE and e.CROSSSUBJGRP=i.SUBJGRPCODE) end) 'Teacher'

    from wsadmin.vw_stu_lateststudent a
    left outer join wsadmin.tb_asr_subjassessdata b on a.suid=b.suid and a.schlvl=b.schlevel and a.schsess=b.schsession and a.classlvl=b.classlevel and a.schyear=b.schyear and a.stuid=b.stuid and b.timeseq=?
    left outer join wsadmin.tb_hse_common c on a.suid=c.suid and b.subjcode=c.code_id and c.tb_id='SBJ'
    left outer join wsadmin.TB_ASR_SUBJCOMASSESSDATA d1 on a.SUID = d1.SUID and a.SCHLVL = d1.SCHLEVEL and a.SCHSESS = d1.SCHSESSION and a.SCHYEAR = d1.SCHYEAR and a.STUID = d1.STUID and b.SUBJCODE = d1.SUBJCODE and b.TIMESEQ = d1.TIMESEQ
    left outer join wsadmin.TB_HSE_SBJCMP d2 on d1.SUID = d2.SUID and d1.SUBJCODE = d2.SBJ_CODE and d1.SUBJCOMPCODE = d2.CODE_ID
    left outer join wsadmin.TB_STU_STUSUBJ e on a.suid=e.suid and a.stuid=e.stuid and b.SUBJCODE = e.SUBJCODE and a.STUSCHRECID=e.STUSCHRECID
    where a.schyear=? and a.classlvl=?
    order by a.classlvl, a.classcode, a.classno, c.ch_des
     
    #2 edb-catherinewschan, 2023-11-16
  3. 59753528

    HUI CHUN KIT
    Expand Collapse

    文章:
    4
    讚:
    0
    Million Thanks!!!!!

     
    #3 HUI CHUN KIT, 2023-11-16