下面的语句不对,正确的应该如何写呢?
update A set 通过数量=(select count(distinct 试卷) from A,B where A.试卷=B.试卷 where B.成绩>60)
谢谢!
...全文
12917打赏收藏
两个表更新数据sql语句
A表(岗位,试卷,通过数量) //一个岗位对应多个试卷; B表(试卷,成绩) 想得到:在A表里的通过数量=该岗位对应的试卷(成绩>60)的数量. 下面的语句不对,正确的应该如何写呢? update A set 通过数量=(select count(distinct 试卷) from A,B where A.试卷=B.试卷 where B.成绩>60) 谢谢!
[Quote=引用 8 楼 yashaov 的回复:]
引用 3 楼 Zhanlixin 的回复:
update A set 通过数量=bb.通过数量 from a,(select 试卷,count(*) 通过数量 from B group by 试卷 where 成绩>60) bb where A.试卷=bb.试卷