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

Endlessrain 2003-07-08 02:56:17
有2张表
表a 是学生的基本信息 字段有id 等
表b 是学生的成绩表 字段有id ,course ,score 其中id 作为外键关联
我想select * from a 并且再加一个sumScore字段,该字段是表b中该学生所有成绩的总和,请教各位这条语句应该怎么写啊?
...全文
45 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
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

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧