Subject Re: [firebird-support] Re: Help
Author Paul Vinkenoog
Hi Eyal,

> 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

This looks like the simplest and best solution so far!

> 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.

I think a lex index on bin_num would help a lot, not for the MAX
(because that will only compare a few values), but for the STARTING
WITH.


Greetings,
Paul Vinkenoog