select studid,sum(cast(courcredit as decimal(18,0))) 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

解决方案 »

  1.   

    select m.studid , 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.studidreupflag是哪个表的?
      

  2.   


    select A.studid,sum(isnull(Bcourcredit,0)) as courcredit
    from e_student A
    left join g_grade B
    on A.studid=B.studid  and  B.courid not like '00%' and B.reupflag='0'
    where classname='KT543-2'
    group by A.studid
      

  3.   


    select 学号=t0.studid,
    学分=sum(isnull(t1.courcredit,0)) 
    from e_student t0
    inner join g_grade t1
    on t0.studid=t1.studid  
    where classname='KT543-2' 
    and  t1.courid not like '00%' 
    and  t1.reupflag='0'
    group by t1.studid