SELECT (((SELECT DISTINCT a.LONGITUDE FROM W6ADMIN.W6ZIPDATA a WHERE a.zipcode=zip)*180)/3.14) INTO lng;
SELECT (((SELECT DISTINCT a.LATITUDE FROM W6ADMIN.W6ZIPDATA a WHERE a.zipcode=zip)*180)/3.14) INTO lat;

SELECT a.*,
POWER((POWER((lat- (W6ADMIN.W6ZIPDATA.LATITUDE*180)/3.14),2)+POWER((lng-(W6ADMIN.W6ZIPDATA.LONGITUDE*180)/3.14),2)),.5) AS Distance
FROM W6ADMIN.W6ENGINEERS a, W6ADMIN.W6ZIPDATA
WHERE RTRIM(a.POSTCODE)=RTRIM(W6ADMIN.W6ZIPDATA.zipcode) AND
(POWER((POWER((lat-(W6ADMIN.W6ZIPDATA.LATITUDE*180)/3.14),2)+POWER((lng-(W6ADMIN.W6ZIPDATA.LONGITUDE*180)/3.14),2)),.5)) <= distance
ORDER BY POWER((lat-(W6ADMIN.W6ZIPDATA.LATITUDE*180)/3.14),2)+POWER((lng-(W6ADMIN.W6ZIPDATA.LONGITUDE*180)/3.14),2);