任何想法爲什麼我的用於UOMC.ToUnitOfMeasure的case語句返回NULL?如果我反轉並顯示To字段之前的字段,將工作,但從不會。使用與THEN相同的字段的多個CASE語句的SQL查詢
SELECT
ECORESPRODUCT.DISPLAYPRODUCTNUMBER,
ECORESPRODUCT.SEARCHNAME,
INVENTTABLE.ITEMID,
UOMC.NUMERATOR,
UOMC.DENOMINATOR,
CASE
WHEN UOMC.FROMUNITOFMEASURE = UOM.RECID
THEN UOM.SYMBOL
ELSE 'NULL'
END AS 'FROM UNIT',
CASE
WHEN UOMC.TOUNITOFMEASURE = UOM.RECID
THEN UOM.SYMBOL
ELSE 'NULL'
END AS 'TO UNIT'
FROM
ECORESPRODUCT
JOIN
INVENTTABLE ON INVENTTABLE.RECID = ECORESPRODUCT.RECID
JOIN
UNITOFMEASURECONVERSION AS UOMC ON UOMC.PRODUCT = ECORESPRODUCT.RECID
JOIN
UNITOFMEASURE AS UOM ON UOM.RECID = UOMC.FROMUNITOFMEASURE
WHERE
INVENTTABLE.NAMEALIAS <> 'Discontinued'
AND INVENTTABLE.COSTGROUPID = 'FG'
你在哪裏檢查結果? SSMS或您的應用程序? –
@ivanStarostin SSMS –
不應該有NULL而不是字符串文字'NULL'? –