SQL SQL

本文由 tr-tic_yws 在 2013-10-02 發表於 "WebSAMS 討論區" 討論區

  1. 55011459

    tr-tic_yws
    Expand Collapse

    文章:
    28
    讚:
    0
    Please kindly provide a SQL query for the figure in % of the number of students who start in F1 and stay on to finish F6 in the past two years. Thanks a lot.
     
    #1 tr-tic_yws, 2013-10-02
  2. 56953375

    edb-石頭
    Expand Collapse

    文章:
    1,160
    讚:
    0
    Pls try the below SQL.

    select
    (select
    count(*)
    from VW_STU_LATESTSTUDENT a
    where a.SCHYEAR=x.schyear and a.classlvl='S6'
    and stuid in (
    select
    distinct b.stuid
    from VW_STU_LATESTSTUDENT b
    where b.classlvl='S1'
    )) 'F6_START_FROM_F1',
    (select
    count(*)
    from VW_STU_LATESTSTUDENT a
    where a.SCHYEAR=x.schyear and a.classlvl='S6'
    ) 'F6_TOTAL',
    (F6_START_FROM_F1*100) / F6_TOTAL '%'
    from (select distinct schyear from TB_SCH_CALFORMAT) x
    where x.schyear=?
     
    #2 edb-石頭, 2013-10-02