Subject Re: Help
Author ez_bikbon
Assuming bin_table/bin_num hold the bin numbers, and search_bin is the
value for which you try to find the best match, try:

SELECT MAX(bin_num) FROM bin_table WHERE :search_bin STARTING WITH bin_num

I tested it on a few values and it seems to do what you want, but of
course you'll have to test more. This is not an efficient query and
indexes can't help much if at all, however if you have up to several
thousands of records it should be ok.

If performance does concern you (ie. the table contains many different
bin numbers) then you can help it by keeping the record size small.
Thus many records fit in a single DB page, so the I/O is minimized to
just a few pages if they're not already in the cache.

For example you can keep a table with the bin numbers only, and use
the result of the search to retrieve the rest of the data from another
table.

Eyal.