I have SQLite database and I have in it certain column of type ‘double’. I want to get a row that has in this column value closest to a specified one.
For example, in my table I have:
id: 1; value: 47 id: 2; value: 56 id: 3; value: 51
And I want to get a row that has its value closest to 50. So I want to receive id: 3 (value = 51).
How can I achieve this goal?
Thanks.
This should work:
Where
?represents the value you want to compare against.