select (t1.a + t2.b) sum
from (select (aa + bb) a from table_x where cc = 'on') t1,
table_y t2
where t1.id = t2.id
The problem is that when t1 is not found, the final result will be null;
How can I make the default value of t2.b to 0, when t1 is not found?
Thx in advance.
You’ll need to use a subquery or a left join if you want to actually return of
nullif it can’t find it. Like so: