尝试获取Dx_3中的输出以打印''
,如果它是NULL
,但我尝试了所有内容(NULLIF()
,COALESCE()
,ELSE ''
等)仍打印NULL
。
SELECT
@RecordType AS RecordType_1
,AbstractData.AccountNumber AS AcctNum_2
,(SELECT
CASE
WHEN AD.Diagnosis IS NOT NULL THEN AD.Diagnosis
ELSE ''
END
FROM AbsDrgDiagnoses AD
WHERE (AD.DiagnosisSeqID ='1' AND AD.VisitID = AbstractData.VisitID)) AS Dx_3
FROM AbstractData --214
WHERE AbstractData.PtStatus <> 'REF'
答案 0 :(得分:1)
SELECT @RecordType AS RecordType_1,
AbstractData.AccountNumber AS AcctNum_2,
COALESCE(AD.Diagnosis, '') AS Dx_3
FROM AbstractData
LEFT JOIN AbsDrgDiagnoses AD ON AD.VisitID = AbstractData.VisitID
WHERE AbstractData.PtStatus <> 'REF' AND AD.DiagnosisSeqID = '1'