I have a table with id, x ,y value ,I need to find the distance between two points using a function in posgresql.
CREATE OR REPLACE FUNCTION distances(lat1 float, lon1 float, lat2 float, lon2 float)
RETURNS float AS $dist$
BEGIN
SELECT ST_Distance(
ST_GeogFromText('SRID=4326;POINT(lat1 lon1 )')
, ST_GeogFromText('SRID=4326;POINT(lat2 lon2)'), false);
END;
$dist$ LANGUAGE plpgsql;
But error throws out when i pass the value:
Kindly give me a sloution.