Postgres geolocation points Distance
postgresql, sql
Solution
ok i solve it checking other questions
SELECT t.* FROM (
SELECT latitude, longitude,SQRT(POW(69.1 * (latitude - 31.8679), 2) +
POW(69.1 * (-116.6567 - longitude) * COS(latitude / 57.3), 2)) AS distance
FROM Locations) t
WHERE distance < 1
ORDER BY distance
Problem
I'm trying to make a query to determinate the distances between geolocation points in a Postgres database this is my query ``` SELECT latitude, longitude, SQRT( POW(69.1 * (latitude - 31.8679), 2) + POW(69.1 * (-116.6567 - longitude) * COS(latitude / 57.3), 2)) AS distance FROM locations HAVING distance < 25 ORDER BY distance ``` but it give me this error ERROR: column "distance" does not exist LINE 5: HAVING distance < 25 if i remove the part "HAVING distance < 25" the query runs OK