Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: HELP - select statement
zak <zak_at_intrafunk.com> schrieb in im Newsbeitrag:
8ubnfl$200s$1_at_ulysses.noc.ntua.gr...
> i've got two tables (people, organizations) and one more (employees) to
link
> these two
> in a many-to-many relation. I want to query the "people" table and when
> there is no data found (null values) in the columns (per_email, per_tel,
> per_addr), i
> want to have their organizations contact data (org_email, org_tel,
> org_addr).
>
> Is there a way to do this with nvl, decode or any other way?
Your question is not unique: Do you mean "no data found" or "null values"? "No data found" sounds more like an outer join problem. But i presume you mean "null values".
Try this:
select ... decode( per_email, null, org_email, per_email ) email, ... from ....
This means: IF per_email IS null THEN USE org_email ELSE USE per_email
regards
Holger Kreft Received on Thu Nov 09 2000 - 09:58:06 CST