Subject Re: [firebird-support] Query help needed
Author Svein Erling Tysvaer
You're right, Rick, this may be simple:

select mt.v2
from MyTable mt
where mt.v1 <= :MyNumber
and not exists(
select *
from MyTable mt2
where mt2.v1 > mt.v1
and mt2.v1 <= :MyNumber)

Set
-it has now been made simpler to donate to the future development of
Firebird at www.firebirdsql.org.

Rick Debay wrote:
> Given the number 25, I'd like to get the value 'B' back from the
> following (simplified) table:
>
> V1 V2
> -- --
> 10 A
> 20 B
> 30 C
>
> Numbers 30 and above should return 'C', and numbers below 20 should
> return 'A'.
> This should be simple, but I just can't think today.
>
> Thanks, Rick DeBay