我试图在计算列别名中使用以下情况,但它显示了语法错误。
[Password_Last_Changed] [datetime] AS
SELECT CASE
WHEN ([SUA_History1_Date] IS NOT NULL) then [SUA_History1_Date]
WHEN ([SUA_History1_Date] IS NULL) then [SUA_History2_Date]
WHEN ([SUA_History2_Date] IS NULL) then [SUA_History3_Date]
WHEN ([SUA_History3_Date] IS NULL) then [SUA_History4_Date]
WHEN ([SUA_History4_Date] IS NULL) then [SUA_History5_Date]
ELSE NULL
END不知道哪里出了问题。如果这个逻辑有更好的方法,请让我试试。
发布于 2016-06-25 11:55:00
发布于 2016-06-18 21:11:25
您可以使用聚结
COALESCE([SUA_History1_Date],[SUA_History2_Date],[SUA_History3_Date],[SUA_History4_Date],[SUA_History5_Date])按顺序计算参数,并返回最初不计算为NULL的第一个表达式的当前值。
https://stackoverflow.com/questions/37901601
复制相似问题