I'm generating a view, and I want to populate cells with a pre-defined value if they are null.
The select for the view is:
SELECT a_case.Id,
R1.Type AS Referred_by_1,
R1.Type AS Referred_by_2,
R1.Type AS Referred_by_3
FROM dbo.CaseInfo a_case LEFT JOIN
dbo.Referrer R1 ON P.Id = R1.Case_Id AND R1.Seq = 1 LEFT JOIN
dbo.Referrer R2 ON P.Id = R2.Case_Id AND R2.Seq = 2 LEFT JOIN
dbo.Referrer R3 ON P.Id = R3.Case_Id AND R3.Seq = 3
The referrers are optional, and if not specified, I need to populate the field with 'ND'.
I think I maybe should be using CASE WHEN, but I'm not sure how to integrate that into the existing select...
Any advice gratefully received! - L