July 31, 2013 at 10:39 am
Hi All,
I just need clarification of why a field for some records would result in a null value for a query like the following, particularly for the StatusCd field. I believe it would be when none of the whens apply? Please advise:
SELECT InternalICN
, EncounterLineNum
, STSDate StatusDt
, case HeaderStatus
when 'F0' then 3 -- PAY
when 'VE' then 3
when 'F2' then 4 -- DENY
when 'P2' then 9 -- SUSPEND
when 'PC' then 10
end AS StatusCd
, case HeaderStatus
when 'VE' then 1500
else 600
end AS StatusReasonCd
, isnull(drec.dpwicn,'') as DPWICN
FROM T277.Enc277_2200D drec join
T277.EncounterTrackingTemp et on et.InternalICN = drec.TraceNo
where et.StatusCd <> 2
Thanks!
July 31, 2013 at 11:12 am
you are correct; you are testing for five specific values in your CASE, and there's no explicit ELSE in it to handle other values, and the built in logic structure of the case returns NULL for items that don't match the tests in the CASE when no explicit ELSE is provided.
Lowell
July 31, 2013 at 11:53 am
Thanks, Lowell. Your response was helpful...I know it's something that may have been obvious, but I just wanted to verify. 🙂
July 31, 2013 at 12:16 pm
Sanity Checks are always a good thing! glad i could help!
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply