Part1. How do I search for values on two different ‘AS’ columns
Part2. How do I list top 5 nearest values to 98?
Example of Query:
select
TITLE.name,
(TITLE.value-TITLE.msp) AS Lower,
(TITLE.value+TITLE.msp) AS Upper
FROM TITLE
WHERE 98 BETWEEN Lower AND Upper;
For part 1), you need to use a nested select, as you cannot use renamed projections (
SELECTpart) as predicates (WHEREpart) in the same subselect.For part 2), use
ORDER BY .. LIMITto get the top 5. Order by the smallest absolute difference to98