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: Beginner SQL question (on intersecting groups of records)....

Re: Beginner SQL question (on intersecting groups of records)....

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 02 Dec 2005 11:01:28 -0800
Message-ID: <1133550074.225129@jetspin.drizzle.com>


dean wrote:
> Hi there, I need to ship something from A to B. I have a group of
> trains T1 that leave station A and head out, and another group of
> trains T2 that I know go to station B.
>
> I want to find out what pairs of trains from T1 and T2 can take me from
> A to B, assuming there are no direct trains. (Actually they are freight
> trains).
>
> Given that a particular train T1a leaves A and hits 100 more stations
> (call it set S), I need to know which trains in group T2 also hit at
> least one of these stations in S. Then I need to do the same thing for
> all trains in T1.
>
> Is there an efficient way to know if there is some intersection between
> the two groups of stations? Like, as soon as one common station is
> found, then stop searching. I could do it with a count, but that is
> going to be way to slow given the number of trains and station records
> foe each train.
>
> Thanks for any help,
>
> Dean

without seeing the sample data ... any answer is a good one or a bad one: Take your pick.

I'm thinking connect by, I'm thinking intersect, I'm thinking inner join, I'm thinking outer join. There are numerous possibilities.

But don't expect anyone here to do your homework for you unless you put their name on the diploma.

-- 
Daniel A. Morgan
http://www.psoug.org
damorgan_at_x.washington.edu
(replace x with u to respond)
Received on Fri Dec 02 2005 - 13:01:28 CST

Original text of this message

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