我要在 SQL BDS 和 衍生列中使用导出列,我想在以下栏中使用导出列:
(1) 如果源列含有 NULLL,则将其替换为“未知”
(2) 如果有数值,则用给定的字符串替换。
到目前为止,我一直想出这个, 但我对这些表达方式的语法不熟悉,
ISNULL(Source) ? "Unknown" : REPLACE("m", "m", "Pop memories" ), REPLACE("h", "h", "Pop hits" ), REPLACE("a", "a", "Pop annual" ), REPLACE("y", "y", "Yearbook" ), REPLACE("bs", "bs", "Bestsellers" )
我敢肯定问题在于每个替换器之间的逗号, 但我不知道还有什么用。有什么建议吗?
编辑:
好吧,我解决了。
ISNULL(Source) ? "Unknown" : REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(Source, "bs", "Bestsellers" ), "m", "Pop memories" ), "h", "Pop hits" ) , "a", "Pop annual" ), "y", "Yearbook" )