请教这条Sql语句应该怎么写?高手请进!

Endlessrain 2003-07-08 02:56:17
有2张表
表a 是学生的基本信息 字段有id 等
表b 是学生的成绩表 字段有id ,course ,score 其中id 作为外键关联
我想select * from a 并且再加一个sumScore字段,该字段是表b中该学生所有成绩的总和,请教各位这条语句应该怎么写啊?
...全文
14 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
stephenlai 2003-07-08
Select a.*,temp.aa from a inner join (Select id,Sum(score) as aa from b Group by id) as tem on a.id=tem.id
回复
Endlessrain 2003-07-08
谢谢,马上给分!
回复
dafu71 2003-07-08
Select a.*, SumScore from a,(Select id,Sum(score) as SumScore from b Group by id)tem where a.id=tem.id
回复
friendliu 2003-07-08
select a.id,a.xm,sum(score)
from a ,b
where a.id=b.id
group by a.id,a.xm
回复
happydreamer 2003-07-08
select a.*,sum(score) as sumScore
from 表a a join 表b b on a.id=b.id
group by a.id,a..... --列表
回复
happydreamer 2003-07-08
select a.*,sum(score) as sumScore
from 表a a join 表b b on a.id=b.id
group by a.id,a..... --列表
回复
97866 2003-07-08
Select a.*,SumScore=tem.aa from a,(Select id,aa=Sum(score) from b Group by id)tem
where a.id=tem.id
回复
wgy2008 2003-07-08
select a.*,b.sum(score)
from a,b
where a.id = b.id
group by a.id
回复
相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2003-07-08 02:56
社区公告
暂无公告