I'm trying to do a join on two tables A and B.
A [id, name]
B [id, ...]
I want to join b.id = a.id, however, if there is no match, i want to specify a value for B to match on (ie the first record in the table).
is that possible?
Printable View
I'm trying to do a join on two tables A and B.
A [id, name]
B [id, ...]
I want to join b.id = a.id, however, if there is no match, i want to specify a value for B to match on (ie the first record in the table).
is that possible?
you may to use Exception
when no_Data_Found then
Begin
Select ...
from B
where your want ...;
end;
(there must be a better way)Code:select
b.id, b.rest,
decode(a1.id, NULL, a2.name, a1.name)
from b, a a1, a a2
where b.id = a1.id(+)
and a2.id = first_row_a_id;