SELECT
n2b.ids,
n2b.levels,
n2b.quantity
FROM
n2b
WHERE
n2b.levels = (select IF((tb1.uppers - 0.9)>(0.9 - tb2.lowers),tb2.levels,IF((tb1.uppers - 0.9)<(0.9 - tb2.lowers),tb1.levels,tb1.levels)) as sum_upper
from ((SELECT n2b.ids, n2b.levels, n2b.quantity as uppers FROM n2b WHERE
n2b.quantity >= 0.9 limit 1) as tb1
JOIN
(SELECT n2b.ids, n2b.levels, n2b.quantity as lowers FROM n2b WHERE
n2b.quantity <= 0.9 order by ids desc limit 1) as tb2))
ORDER BY
ids DESC
LIMIT 1
ไม่มีความคิดเห็น:
แสดงความคิดเห็น