Get value from nearest (lower) integer As jkavalik sais: I'm looking for "the greatest value not greater than". I have a table containing a kind of IDs and values like those

ID     value
101    A
2003   B
4005   C



when searching for "2003" I want to get "B" 
when searching for "2004"I want to get "B", too. 
when searching for "2002" I want to get "A"


If a always had exact matching IDs i would write 

SELECT value FROM table WHERE id = 2003


But is there a way to handle my problem describe above? I'm using firebird 2.5.
SELECT FIRST 1 value FROM table WHERE id &lt;= 2003 ORDER BY id desc


Get the greatest value not greater than.