sql case when 多条件不能用于表达式的相加或相乘吗

2025-04-06 19:45:20
推荐回答(1个)
回答1:

你写的也太乱了吧,而且也没描述出想要什么效果?我给你改了一下你看看对不对。

CREATE VIEW ABC
as
slect
W=case
when A2 is null then B2
else A2
end,
E=case
when A1 is null then C1
else A1
end
from A join C on A1=C1 join B on C2=B2
或者简化一下,直接写:
CREATE VIEW ABC
as
slect
W=ISNULL(A2,B2),
E=ISNULL(A1,C1)