Distance Calculation (long, lat)


Hello, Im trying to calculate distance between two different locations. I’ve tried using something like this ST_Distance_Sphere(point(s.point_x,s.point_y), point(121.1005,14.5973)), but this function does not work. are there any functions which I can use for distance calculation for two locations?


Hello, it depends on the database you are using, note redash I think.
I suppose you are using PostGIS so this should work :

SELECT ST_Distance_Sphere(st_setsrid(st_makepoint(s.point_x,s.point_y),4326), st_setsrid(st_makepoint(121.1005,14.5973),4326)) 

Yous should also use ST_GeomFromText instead of st_setsrid(st_makepoint(…),…)