Answer the question
In order to leave comments, you need to log in
How to organize such a double request?
I need to make a double selection - first select all the values from the table where side="bright", and then find the closest values to my given value in the results (for example, 100). I understand that in the second one there should be something like ABS(100 - results) and you need to use a double query, but I don’t understand how to implement it at all.
Answer the question
In order to leave comments, you need to log in
Something like?
SELECT *, ABS(100 - results) AS diff
FROM t
WHERE side = 'bright'
ORDER BY diff ASC
LIMIT 5
I think you need something like
SELECT *
FROM (
SELECT TOP 10 ABS(100 - result) as diff
FROM t
WHERE side = 'bright') b
WHERE diff < 20
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question