If you do a LEFT JOIN
and no records exist in B
, you will get a null
for the column values in B
. So to "prefer" valued that exist in B
, use COALESCE
:
SELECT COALESCE(B.Sales, C.Sales) AS Sales
FROM ...
Which loosely translates to "If B
has a Sales
value, use it, otherwise use the value from C
."
Technically it means "take the first non-null value from B.Sales
and C.Sales
(in that order)"