sql server - SQL View - add default values if null? -
i'm generating view, , want populate cells pre-defined value if null.
the select view is:
select a_case.id, r1.type referred_by_1, r1.type referred_by_2, r1.type referred_by_3 dbo.caseinfo a_case left join dbo.referrer r1 on p.id = r1.case_id , r1.seq = 1 left join dbo.referrer r2 on p.id = r2.case_id , r2.seq = 2 left join dbo.referrer r3 on p.id = r3.case_id , r3.seq = 3
the referrers optional, , if not specified, need populate field 'nd'.
i think maybe should using case when, i'm not sure how integrate existing select...
any advice gratefully received! - l
you can use isnull
:
select a_case.id, isnull(r1.type, 'nd') referred_by_1, isnull(r2.type, 'nd') referred_by_2, isnull(r3.type, 'nd') referred_by_3 ...
Comments
Post a Comment