select studid,studname,sum(cast(courcredit as decimal(18,0))) as courcredit,sum(achievequot) from g_grade where exists
(
select studid from e_student where 
courid not like '00%' and reupflag = '0'  and e_student.studid = g_grade.studid and classname = 'KT543-2'
)
group by studid,studname

解决方案 »

  1.   

    select m.studid ,m.StudName, sum(cast(courcredit as decimal(18,0))) as courcredit
    from e_student as m , g_grade as n 
    where m.studid = n.studid and n.courid not like '00%' and reupflag = '0'  and m.classname = 'KT543-2'
    group by m.studid,m.StudName
      

  2.   


    select 
        a.studid,b.studname,sum(cast(a.courcredit as decimal(18,0))) as courcredit,sum(a.achievequot) 
    from 
        g_grade a,e_student b
    where 
        a.studid=b.studid
        and
        exists(select 
                   studid 
               from 
                   e_student 
               where 
                   courid not like '00%' and reupflag = '0'  and e_student.studid = g_grade.studid and classname = 'KT543-2')
    group by 
        a.studid,b.studname
      

  3.   

    select m.studid , m.StudName , sum(courcredit) courcredit
    from e_student m , g_grade n 
    where m.studid = n.studid and m.courid not like '00%' and reupflag = '0'  and m.classname = 'KT543-2'
    group by m.studid, m.StudName
      

  4.   

    ---方法一
    select m.studid ,m.stuName, sum(cast(courcredit as decimal(18,0))) as courcredit
    from e_student as m , g_grade as n 
    where m.studid = n.studid and n.courid not like '00%' and reupflag = '0'  and m.classname = 'KT543-2'
    group by m.studid,m_stuName---方法二
    select t.*,tt.stuName from (
    (
    select m.studid , sum(cast(courcredit as decimal(18,0))) as courcredit
    from e_student as m , g_grade as n 
    where m.studid = n.studid and n.courid not like '00%' and reupflag = '0'  and m.classname = 'KT543-2'
    group by m.studid
    ) t join e_student tt on t.stuid = b.stuid
      

  5.   

    select a.studid,b.StudName,a.courcredit,a.achievequot
    from
    (
    select studid,sum(cast(courcredit as decimal(18,0))) as courcredit,sum(achievequot) as achievequot from g_grade where exists
    (
    select studid from e_student where 
    courid not like '00%' and reupflag = '0'  and e_student.studid = g_grade.studid and classname = 'KT543-2'
    )
    group by studid
    ) as a
    left outer join e_student as b on a.studid = b.studid