Re: Can this be done?

From: Maxim Demenko <mdemenko_at_gmail.com>
Date: Mon, 08 Aug 2011 00:32:14 +0200
Message-ID: <4e3f1253$0$7628$9b4e6d93_at_newsspool1.arcor-online.net>



On 07.08.2011 22:55, sheldonlg wrote:
> I have two tables
> A: field1, field2
> B: field1, field2
>
> field2 always has a value in table A.
> table B may or may not have a record with a value of field1 matching
> that of table A.
>
> I want to get the value of field2. I want the value for the record with
> the value of field1 to come from Table B if there is a record there for
> that value of field1, otherwise I want the value to come from table A.
>
> If that is confusing, here is an example:
>
> Table A
> field1 field2
> 101 39
> 102 75
> 103 94
> 104 66
>
> Table B
> field1 field2
> 102 81
> 104 67
>
> I want the results to be for the query for records where field1 IN
> (101,102) obtained to be
>
> field1 field2
> 101 39
> 102 81
>
> Any hints?
>

select A.field1,nvl(B.field2,A.field2)
from tableA A,tableB B
where A.field1=B.field1(+)
and A.field1 in (101,102)

Best regards

Maxim Received on Sun Aug 07 2011 - 17:32:14 CDT

Original text of this message