我有以下 SQL 语句:
update data
set [sub_st_pc]=
case
when [R 6] is not null then [R 6]
when [R 5] is not null then [R 5]
when [R 4] is not null then [R 4]
when [R 3] is not null then [R 3]
when [R 2] is not null then [R 2]
else sub_st_pc
end
但我需要根据每个时间更新另一列,如下所示:
when [R 6] is not null then [R 6], [temp] = 6
when [R 5] is not null then [R 5], [temp] = 5
我知道这是错误的。
有任何想法吗?