Re: Box query

From: Mikito Harakiri <mikharakiri_nospaum_at_yahoo.com>
Date: 21 Apr 2006 19:14:12 -0700
Message-ID: <1145672052.520635.287470_at_i39g2000cwa.googlegroups.com>


Mikito Harakiri wrote:
> Mikito Harakiri wrote:
> > Given a set of n-dimensional boxes
> > find all the pairs that intersect...
>
> table boxes (
> *id* integer,
> dimension# integer,
> low integer,
> high integer
> )

Here is relational division style of query:

select b1.id as box1, b2.id as box2, b1.dim from boxes b1, boxes b2
where b1.low between b2.low and b2.high
and b1.dim = b2.dim
group by b1.id, b2.id
having count(1) = (

        select count(1) from boxes b3
        where b3.id = b1.id
        and b3.dim=b1.dim

)

Yet, again with Bob's solution I can't claim it to be "special" anymore... Received on Sat Apr 22 2006 - 04:14:12 CEST

Original text of this message