Originally posted by slimdave
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
That was my initial thougt too, however it turned out that DoCalculate() is still called twice for any row returned! At least on 9.0.1.