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 for

Re: SQL for

From: Edorta <edortta_at_yahoo.es>
Date: Fri, 19 Nov 1999 10:53:21 +0100
Message-ID: <38351E11.FF442BB5@yahoo.es>


If there are more posible values of foo, you can use a where:

"select bar from foobar
where foo between 1 and 3
group by bar
having count(distinct(foo)) > 2;"

Edorta wrote:

> I think this select does the work:
>
> "select bar from foobar
> group by bar
> having count(distinct(foo)) > 2;"
>
> Hope this helps,
> Edorta
>
> danielsomerfield_at_my-deja.com wrote:
>
> > Hello, I was wondering if someone could help me with a query. I have
> > found a long, rather convoluted inefficient way to do it and I am
> > wondering if there is a better one. If I have a table like so:
> > foobar
> > foo | bar
> > |
> > ---------
> > 1 | a
> > 1 | b
> > 1 | c
> > 2 | a
> > 3 | a
> > 3 | b
> >
> > I wish to get all the "bar"s which have "foo"s of 1, 2 and 3. So the
> > answer above is "a". The query I came up with is:
> >
> > SELECT bar FROM foobar WHERE foo = 1
> > INTERSECT
> > SELECT bar FROM foobar WHERE foo = 2
> > INTERSECT
> > SELECT bar FROM foobar WHERE foo = 3;
> >
> > Ugly and cumbersome. What do you think? Is there something a bit more
> > elegant?
> >
> > Dan
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
Received on Fri Nov 19 1999 - 03:53:21 CST

Original text of this message

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