"Pankaj" <
harpre...@gmail.com> wrote in message
news:2f9bb59a-e348-4506...@e13g2000vbn.googlegroups.com...
I'd second all comments from Charles Hooper about you current approach, and
the correction.
The current approach should include a build script for your sample data so
that we don't fly off at a tangent to what you need.
Here's the outline for a solution to a problem that might be the one you
want solved:
select
*
from (
(
select max(range_col) low_range
from range_table
where range_col <= :input_value
) v1,
(
select min(range_col) high_range
from range_table
where range_col >= :input_value
) v1
)
Strategy: find the largest value that is not greater than the input, and
the smallest value that is not less than the input.
Only suitable for one input value, and needs rethinking for joins involving
the range.
Optimal performance comes from an index on (range_col) that allows the
optimize to use a "range scan (min/max)"
--
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com/all-postings
Author: Oracle Core (Apress 2011)
http://www.apress.com/9781430239543