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: Mike Burden <michael.burden_at_capgemini.co.uk>
Date: Tue, 30 Mar 1999 08:51:43 +0000
Message-ID: <3700828E.7C6F132B@capgemini.co.uk>


I'm not sure what you mean by first. It only really becomes useful after a sort. If you're after the lowest value then you could use the MIN aggregation function.

e.g.

select a.id,min(value)
from a,b
where a.id = b.id
group by a;

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 - 02:51:43 CST

Original text of this message

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