Re: sql to find a numeric range inside another range?

From: dbarchitech <noble_kid_at_mac.com>
Date: 4 Mar 2004 12:27:17 -0800
Message-ID: <9d3dc423.0403041227.79c5ef4e_at_posting.google.com>


"Mark C. Stock" <mcstockX_at_Xenquery .com> wrote in message news:<ePydnbw8FsucidjdRVn-uA_at_comcast.com>...
> "dbarchitech" <noble_kid_at_mac.com> wrote in message
> news:9d3dc423.0403021434.18a3078e_at_posting.google.com...
> | hi,
> |
> | i'm building a query to find narrow ranges of zip codes within broader
> | ranges in a table (for tax purposes). for example:
> |
> | LOW_ZIP HI_ZIP
> | 23400 23499
> |
> | need to find
> | 23401 23402
> | 23403 23440
> | 23441 23... you get the picture. :)
> |
> | so, each row has a low value and a hi value, then i need to run a
> | subquery to take those values and find narrower ranges. any ideas?
>
> yeah, but you got to show us yours first ;-)
>
> ;-{ mcs

yeah, well mine doesn't work!!! :-$

select sales_tax_id,
from_postal_code,
to_postal_code
from ar_sales_tax a,
(select from_postal_code as fpc,

           to_postal_code as tpc
           from ar_sales_tax
           where rowid = rowid) b

where from_postal_code between b.fpc and b.tpc and to_postal_code between b.fpc and b.tpc and end_date is null

i need to somehow scan the entire table row by row looking for records that fit within the ranges... i'm thinking i may need to do this using a cursor.

-cam Received on Thu Mar 04 2004 - 21:27:17 CET

Original text of this message