The following query:
CREATE PROCEDURE GetDistance AS
SELECT a.ZIPCODE, a.CITY, a.STATE,
ROUND(
(ACOS(
(SIN(c.LATITUDE) * SIN(a.LATITUDE)) +
(COS(c.LATITUDE) * COS(a.LATITUDE) *
COS(a.LONGITUDE - c.LONGITUDE))
)
)
* 3963,1
) AS distance
FROM Zipcodes a, Zipcodes c
WHERE (
ACOS(
(SIN(c.LATITUDE) * SIN(a.LATITUDE)) +
(COS(c.LATITUDE) * COS(a.LATITUDE) * COS(a.LONGITUDE - c.LONGITUDE))
)
) * 3963 <= '10'
AND c.ZIPCODE='80222'
ORDER BY distance
GO
tells me that the only zipcode within 10 miles of 80222 is 80222 and if I replace 10 with 25 it offers only one additional zip code? Does anyone have any ideas why this might be happening?
Thanks so much for any suggestions anyone has to offer.:rolleyes: