Answer the question
In order to leave comments, you need to log in
How to get the closest value that is less than a given one?
There is a table with numbers. The table is sorted in ascending order of these numbers. How can I find a table row with a number closest to a given number (let's say 100) but less than it?
Answer the question
In order to leave comments, you need to log in
A separate row with the closest value to the specified one can be obtained like this
SELECT *
FROM my_numbers
WHERE my_num < 100
ORDER BY my_num desc
LIMIT 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question