我在下面有case
语句,但是尽管它具有应触发大小写的值,但我仍然得到null。有明显的错误吗?
SELECT
*,
(CASE
WHEN topicname = 'TPOSTAL_CODE'
THEN (SELECT LTRIM(RTRIM(ALS_C)) AS LocationCode
FROM ODS.TBUS_LOC
WHERE cci.columna = ods.TBUS_LOC.BUS_LOC_I)
WHEN topicname = 'TBUSINESS_SITE'
THEN (SELECT LTRIM(RTRIM(B.ALS_C)) AS LocationCode
FROM ODS.TBUSINESS_SITE A
INNER JOIN ODS.TBUS_LOC B ON A.BUS_LOC_ID = B.BUS_LOC_I
WHERE cci.columna = A.BUS_LOC_ID)
END) AS Code
FROM
[XREF].[tablea] CCI
CCIEntityName
带有独特的
答案 0 :(得分:0)
主题名称可能在开头或结尾处都包含空格。这些可能不容易被眼睛看到。您可以尝试
ltrim(rtrim(topicname))='TPOSTAL_CODE'的情况
看看是否有区别。