DROP TABLE #bbb
SELECT DISTINCT
Mrn.PrefixMedicalRecordNumber AS 'Key',
DATEDIFF(YY,Him.Birthdate,Bar.DischargeDate) AS 'Age',
CASE
WHEN DATEDIFF(YY, Him.Birthdate, Bar.DischargeDate) < '1'
THEN DATEDIFF(d, Him.Birthdate, Bar.DischargeDate)
ELSE ''
END AS 'AgeDay'
请帮助我,在ageday
列中我应该能看到空字符串而不是null或o但现在我看到0
答案 0 :(得分:0)
SELECT DISTINCT
Mrn.PrefixMedicalRecordNumber as 'Key'
,DATEDIFF(YY,Him.Birthdate,Bar.DischargeDate) as 'Age'
,CASE WHEN DATEDIFF(YY,Him.Birthdate,Bar.DischargeDate) < 1
THEN ISNULL(NULLIF(CAST(DATEDIFF(d,Him.Birthdate,Bar.DischargeDate) AS VARCHAR(10)) , 0) , '')
ELSE''
END as 'AgeDay'