BEGIN
DECLARE Distance REAL DEFAULT 0;
DECLARE EARTH_RADIUS REAL DEFAULT 6378.137;
DECLARE RadLatBegin REAL DEFAULT 0;
DECLARE RadLatEnd REAL DEFAULT 0;
DECLARE RadLatDiff REAL DEFAULT 0;
DECLARE RadLngDiff REAL DEFAULT 0;
SET RadLatBegin = LatBegin * PI() / 180.0;
SET RadLatEnd = LatEnd * PI() / 180.0;
SET RadLatDiff = RadLatBegin - RadLatEnd;
SET RadLngDiff = LngBegin * PI() / 180.0 - LngEnd * PI() / 180.0;
SET Distance = 2 * ASIN(SQRT(POWER(Sin(RadLatDiff / 2), 2) + COS(RadLatBegin) * COS(RadLatEnd) * POWER(SIN(RadLngDiff/2),2)));
SET Distance = Distance * EARTH_RADIUS;
RETURN ROUND(Distance,1);
END