简易代码之家

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  157 Posts :: 2 Stories :: 57 Comments :: 0 Trackbacks

student:name,sex,age
score:name,subject,score

想要的结果:name,sex,age,sum(score)

1.
select s.name,s.sex,s.age,(select sum(c.score) from score c where c.name = s.name) from student s;
2.
select s.name,s.sex,s.age,sc.total from (select sum(c.score) as total,c.name
from score c group by c.name) sc inner join student s on s.name = sc.name;

posted on 2010-08-12 15:15 Jakin.zhou 阅读(143) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: