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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Getting single (first) value from many side of a 1-to-many join??

Re: Getting single (first) value from many side of a 1-to-many join??

From: Andrew Babb <andrewb_at_mail.com>
Date: Tue, 30 Mar 1999 15:41:48 +0800
Message-ID: <3700803C.BAF3F42@mail.com>


Greg,

An option, that might work would be;

select t1.id, min(t2.value)
  from table1 t1

     , table2 t2
 where t1.id = t2.id
 group by t1.id;

Would this provide your correct data set?

Andrew

Greg Schetinin wrote:

> Help!!
>
> I need a Select that will let me join 2 tables in a one to many
> relationship but I only want my result to contain a single 'record'
> with the first value from the many side.
>
> ex. Table1 Table2
> id id , value
>
> data 1 1,a
> 1,b
> 1,c
> 2 2,d
> 2,e
>
> Joining by id I'm getting:
>
> 1,1,a
> 1,1,b
> 1,1,c
> 2,2,d
> 2,2,e
>
> I want:
> 1,1,a
> 2,2,d
>
> There are no values in Table2 to identify the correct record to use.
>
> I've searched and can't find a solution. Any ideas?
>
> Thanks in advance for any help!
Received on Tue Mar 30 1999 - 01:41:48 CST

Original text of this message

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