我有一个包含数字列表的数组,例如:[20,10,40,10,15],如何使用SQL查询在此数组中找到最近的元素?
lets assume you have table values
like: id|value and need to find value closest to 5
then
SELECT value from values where abs(value - 5) = (select min(abs(value -5)) from values)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.