Use a combination of min()
and abs()
:
select num
from mytable
where abs(num) = (select min(abs(num)) from mytable)
To break ties, apply min() or max() to num to get the negative or positive side, eg
To get the negative of a tie:
select min(num) num
from mytable
where abs(num) = (select min(abs(num)) from mytable)
To get the positive of a tie:
select max(num) num
from mytable
where abs(num) = (select min(abs(num)) from mytable)