SQL 校外及校內獎項

本文由 LI LAI KUEN 在 2011-12-22 發表於 "WebSAMS 討論區" 討論區

  1. 55639564

    LI LAI KUEN
    Expand Collapse

    文章:
    30
    讚:
    0
    請問, 我想用 SQL 抽取校外及校內獎項和得獎年份,
    成段 SQL 點寫??

    Thanks
     
    #1 LI LAI KUEN, 2011-12-22
  2. 56424333

    edb-stsim2
    Expand Collapse

    文章:
    258
    讚:
    0
    未知老師所指的校外獎項是指什麼?若是校內的獎,可以參考這裡
     
    #2 edb-stsim2, 2011-12-22
  3. 55639564

    LI LAI KUEN
    Expand Collapse

    文章:
    30
    讚:
    0
    類似 SLP 其中有兩版係
    "校內頒發的主要獎項及成就" 及
    "校外的表現 / 獎項"

    Thanks
     
    #3 LI LAI KUEN, 2011-12-22
  4. 56953375

    edb-石頭
    Expand Collapse

    文章:
    1,160
    讚:
    0
    老師請參考以下的 SQL 語句。

    select
    schoolyear '學年',
    classlevel '級別',
    classcode '班別',
    classno '班號',
    chname '中文姓名',
    enname '英文姓名',
    Types,
    years '日期',
    description '說明'
    from
    (select
    b.schyear 'Schoolyear',
    b.classlvl 'classlevel',
    b.classcode 'classcode',
    b.classno 'classno',
    b.chname 'chname',
    b.enname 'enname',
    '校內' 'Types',
    cast(dateformat(a.anpdate, 'YYYY') as text) 'years',
    ((case when trim(a.prefix)<>'' then a.prefix else '' end) + (case when trim(a.descriptionstr)<>'' then a.descriptionstr else '' end) + (case when trim(a.descriptioncode)<>'' then c.ch_des else '' end) + (case when trim(a.position)<>'' then a.position else '' end) + (case when trim(a.naaofferedid)<>'' then e.ch_des else '' end)) 'description'
    from tb_stu_anpsturec a
    join vw_stu_lateststudent b
    on a.suid=b.suid and a.stuid=b.stuid and a.schyear=b.schyear
    left outer join tb_naa_naaoffered d
    on a.suid=d.suid and a.schyear=d.schyear and a.naaofferedid=d.naaofferedid
    left outer join tb_hse_common e
    on a.suid=e.suid and d.naacode=e.code_id
    and ((e.tb_id='ECACD' and d.naatype='E')
    or (e.tb_id='SEVPST' and d.naatype='S')
    or (e.tb_id='INTERSCH' and d.naatype='I'))
    left outer join tb_hse_common c
    on a.suid=c.suid and a.descriptioncode=c.code_id and c.tb_id='PRIZE'
    where a.anptype='A'
    union all
    select
    d1.schyear,
    d1.classlvl ,
    d1.classcode ,
    d1.classno ,
    d1.chname ,
    d1.enname ,
    '校外' ,
    c1.STARTYR ,
    c1.PROG || ' - ' ||c1.PROG_DES
    from TB_SLP_STU_PERFME_OUTSCH c1
    join vw_stu_lateststudent d1.
    on c1.suid=d1.suid and c1.stuid=d1.stuid) act
    where schoolyear=? and classlevel = ?
    order by classcode, classno
     
    #4 edb-石頭, 2011-12-22
  5. 55639564

    LI LAI KUEN
    Expand Collapse

    文章:
    30
    讚:
    0
    E-16053 : SQL語句不正確

    Thanks
     
    #5 LI LAI KUEN, 2011-12-23
  6. 56953375

    edb-石頭
    Expand Collapse

    文章:
    1,160
    讚:
    0
    老師請再參考以下的 SQL 語句。

    select
    schoolyear '學年',
    classlevel '級別',
    classcode '班別',
    classno '班號',
    chname '中文姓名',
    enname '英文姓名',
    Types,
    years '日期',
    description '說明'
    from
    (select
    b.schyear 'Schoolyear',
    b.classlvl 'classlevel',
    b.classcode 'classcode',
    b.classno 'classno',
    b.chname 'chname',
    b.enname 'enname',
    '校內' 'Types',
    cast(dateformat(a.anpdate, 'YYYY') as text) 'years',
    ((case when trim(a.prefix)<>'' then a.prefix else '' end) + (case when trim(a.descriptionstr)<>'' then a.descriptionstr else '' end) + (case when trim(a.descriptioncode)<>'' then c.ch_des else '' end) + (case when trim(a.position)<>'' then a.position else '' end) + (case when trim(a.naaofferedid)<>'' then e.ch_des else '' end)) 'description'
    from tb_stu_anpsturec a
    join vw_stu_lateststudent b
    on a.suid=b.suid and a.stuid=b.stuid and a.schyear=b.schyear
    left outer join tb_naa_naaoffered d
    on a.suid=d.suid and a.schyear=d.schyear and a.naaofferedid=d.naaofferedid
    left outer join tb_hse_common e
    on a.suid=e.suid and d.naacode=e.code_id
    and ((e.tb_id='ECACD' and d.naatype='E')
    or (e.tb_id='SEVPST' and d.naatype='S')
    or (e.tb_id='INTERSCH' and d.naatype='I'))
    left outer join tb_hse_common c
    on a.suid=c.suid and a.descriptioncode=c.code_id and c.tb_id='PRIZE'
    where a.anptype='A'
    union all
    select
    d1.schyear,
    d1.classlvl ,
    d1.classcode ,
    d1.classno ,
    d1.chname ,
    d1.enname ,
    '校外' ,
    c1.STARTYR ,
    c1.PROG || ' - ' ||c1.PROG_DES
    from TB_SLP_STU_PERFME_OUTSCH c1
    join vw_stu_lateststudent d1
    on c1.suid=d1.suid and c1.stuid=d1.stuid) act
    where schoolyear=? and classlevel = ?
    order by classcode, classno
     
    #6 edb-石頭, 2011-12-23
  7. 55639564

    LI LAI KUEN
    Expand Collapse

    文章:
    30
    讚:
    0
    不好意思
    "校內獎項" 的數據不對 SLP 我看到的一樣
    是否另外一個?

    Thanks
     
    #7 LI LAI KUEN, 2011-12-23
  8. 56953375

    edb-石頭
    Expand Collapse

    文章:
    1,160
    讚:
    0
    "校內獎項"是抽取"獎懲資料"模組內所輸入的學生獎項資料, 而 SLP 報表是用 stored procedure 抽取資料, SQL 並不能像 stored procedure 般抽取資料, 應該比較"獎懲資料"模組內的資料.
     
    #8 edb-石頭, 2011-12-23
  9. 55639564

    LI LAI KUEN
    Expand Collapse

    文章:
    30
    讚:
    0
    好!!
    謝謝你!!
     
    #9 LI LAI KUEN, 2011-12-23
  10. 55639564

    LI LAI KUEN
    Expand Collapse

    文章:
    30
    讚:
    0
    本人想用以上 SQL 更改成下列附件的資料
    能否一行列出一位學生的資料??
    如果可以又怎麼樣做呢??

    謝謝你!!
     

    附件文件:

    • S7.pdf
      文件大小:
      73 KB
      瀏覽:
      3,081
    #10 LI LAI KUEN, 2012-05-21
  11. 56953375

    edb-石頭
    Expand Collapse

    文章:
    1,160
    讚:
    0
    1)請老師提供操行的詳細資料 2) award1,award2,act1,act2 etc...SQL並不支援varable columns 功能, 建議老師用crystal report中cross tab功能.
     
    #11 edb-石頭, 2012-05-22
  12. 55639564

    LI LAI KUEN
    Expand Collapse

    文章:
    30
    讚:
    0
    1) 想要怎麼詳細資料?? 有沒有例子??
    2) 如果我唔用 award1,award2,act1,act2
    我用 award , awardYear, act, actRole, actYear
     

    附件文件:

    • S7v1.pdf
      文件大小:
      72.3 KB
      瀏覽:
      3,048
    #12 LI LAI KUEN, 2012-05-23
  13. 56953375

    edb-石頭
    Expand Collapse

    文章:
    1,160
    讚:
    0
    老師請聯絡貴校的網上校管系統學校聯絡主任。
     
    #13 edb-石頭, 2012-05-23