我的原始查询如下。即使在放置条件之后,我也应该得到' 2100-12-31'作为输出。但它的结果是NULL任何身体都可以帮助我。
case ty.[ASSC_3PRTY_END_DT]
when NULL THEN '2100-12-31'
ELSE replace(convert(varchar,ty.[ASSC_3PRTY_END_DT], 111),'/','-')
END AS thirdPartyAccessLastDate,
输出:
NULL
完整查询是:
DECLARE @STUDENTID VARCHAR(10)='804403895'
SELECT ty.[STU_ID],
ty.UCLA_3PRTY_ID,
ty.ASSC_3PRTY_DESC,
dr.FIRST_NAME_3PRTY,
dr.LAST_NAME_3PRTY,
dr.EMAIL_ADDR_3PRTY,
replace(convert(varchar,ty.[ASSC_3PRTY_STRT_DT], 111),'/','-') thirdPartyAccessStartDate,
case ty.[ASSC_3PRTY_END_DT]
when NULL THEN '2100-12-31'
ELSE replace(convert(varchar,ty.[ASSC_3PRTY_END_DT], 111),'/','-')
END AS thirdPartyAccessLastDate,
case when ty.[ASSC_3PRTY_END_DT] IS NULL or ty.[ASSC_3PRTY_END_DT] > GETDATE() then 'Y'
else 'N'
end as thirdPartyAccessActive
FROM DBO.SI0_STU_3PRTY ty left join dbo.SI0_3PRTY_DIR dr on ty.UCLA_3PRTY_ID=dr.UCLA_3PRTY_ID
where ty.STU_ID = @STUDENTID