22,298
社区成员
发帖
与我相关
我的任务
分享

,请问SQL语句怎么写才可以实现这样的结果
update B
set b.ucount = case when a.name IS NULL THEN 1 ELSE 0 END + case when a.age IS NULL THEN 1 ELSE 0 END
from student a
join studentversion b
on a.id = b.studentid
update A
set a.name=ISNULL(a.name, b.name), a.age = ISNULL(a.age, b.age)
from student a
join studentversion b
on a.id = b.studentid
update A
set a.name=ISNULL(a.name, b.name), a.age = ISNULL(a.age, b.age), a.ucount = case when a.name IS NULL THEN 1 ELSE 0 END
+ case when a.age IS NULL THEN 1 ELSE 0 END
from student a
join studentversion b
on a.id = b.studentid