select * from
(
select DoCalculate(aLongitude,aLATITUDE,a.LONGITUDE,a.LATITUDE) mileage_calcualted
from TABLEx a
)
where mileage_calcualted is not null;

Better if you can to express the function behind DoCalculate in SQL