Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: sql return only first matching record from join table

Re: sql return only first matching record from join table

From: Gene Hubert <gwhubert_at_hotmail.com>
Date: 5 Jul 2002 10:36:00 -0700
Message-ID: <7e3fa619.0207050935.14a697c1@posting.google.com>


>jbarney_ca_at_yahoo.ca (Barnoit) wrote in message news:<cd2c60c8.0207040634.1bbc5deb_at_posting.google.com>...
>> I posted this in a follow-up to Martin, but I think the answer to my
>> second question is to place the (select min(rowid)...)as x in the from
>> clause and alias that (x) and then use an outer join on x in the where
>> clause something like ... and occupant.rowid(+) in x.rowid. This seems
>> to work, but if anyone has any suggestions/improvements I'd appreciate
>> hearing them.
>>
>> Thanks
>>
>

Try using an inline view as in:

select a.address, o.min_occ
from
address_table a,
(
 select address_id, min(occupant) min_occ  from occupant_table group by address_id ) o
where a.address_id = o.address_id (+)
;

Gene Hubert
Durham, NC Received on Fri Jul 05 2002 - 12:36:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US