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 help

Re: sql help

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Tue, 07 May 2002 20:25:09 GMT
Message-ID: <3CD8381D.382F11E3@exesolutions.com>


Brian wrote:

> Hello all,
>
> I'm having difficulties completing this query. I have a table with a
> primary key of ID1 and a foriegn key of ID2. What I want my qeury to
> do is return one primary key (ID1) for each foreign key. Example:
> From the table below -
>
> ID1 ID2
> ---------- ----------
> 4198 5511601
> 31380 5511601
> 1454716 5511601
> 1455577 5511601
> 1455637 5511601
> 1456244 5511601
> 1489157 5511601
> 1503752 5511601
> 15068 23544883
> 42821 23544883
> 1390131 23544883
>
> ID1 ID2
> ---------- ----------
> 1418794 23544883
>
> Query with a result of -
>
> ID1 ID2
> ---------- ----------
> 4198 5511601
> 15068 23544883
>
> I've tried using group by and can't figure out what I need to do.
> Any help would be great!!
>
> TIA
>
> Brian

There are a number of ways this could be accomplished. But SQL, and I, have a difficult time figuring out how to know that you want 4198 with 5511601 rather than any other value. Is your criterion ... "give me one and I don't care which one"?

Consider using the MIN or MAX function if that is the case.

Daniel Morgan Received on Tue May 07 2002 - 15:25:09 CDT

Original text of this message

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