我要读取表A中的所有字段,同时得到字段sum(Grade) as GrageSum,按StudentName分组的,就是说相等StudentName,只取出其中一行数据,但是要汇总相等StudentName所有的Grade,谢谢!
------解决方案--------------------
select studentname,sum(grade),max(col1),max(col2),...max(coln)
from tb
group by studentname
------解决方案--------------------
select studentname,col1,col2,..., --写全字段,除了grade
(select sum(grade) from tb where studentname=a.studentname) as grade
from tb a
where not exists (
select 1 from tb
where studentname=a.studentname
and key <a.key
)