I have a database of coordinates in the schema:
ID:Latitude:Longitude:name:desc
I\'ve set up my google maps application to show the markers effectively on the sc
This SQL gives more accurate answer:
SELECT *
FROM Table1 a
WHERE 1 = 1
AND 2 * 3961 * asin(sqrt( power((sin(radians((X - cast(a.latitude as decimal(10,8))) / 2))) , 2) + cast(cos(radians(cast(a.latitude as decimal(18,8)))) * cos(radians(X)) * power((sin(radians((Y - cast(a.long as decimal(18,8))) / 2))) , 2) as decimal(18,10) ))) <= Radius_In_Miles
X = Latitude of Centroid Y = Longitude of Centroid
I did it in Redshift, so I had to use cast to prevent numeric value overflow error.
Reference: http://daynebatten.com/2015/09/latitude-longitude-distance-sql/