Harsh Reddy
Harsh Reddy

Reputation: 203

Lat Lon Distance Calculation query in Oracle

I have a Oracle 11g DB. I store Latitude and Longitudes (for lets say stores or shops). Now i need a query which will calculate the distance between the shops and my location(which i will provide in the query). I have done this earlier in MySQL, but in Oracle there is no Radians function. So i need work aronud in Oracle SQL.

Help Appreciated. Thank You.

Upvotes: 2

Views: 5001

Answers (2)

Wernfried Domscheit
Wernfried Domscheit

Reputation: 59642

or even more precise:

RETURN p_degree /(180/ACOS(-1));

Upvotes: 2

Alen Oblak
Alen Oblak

Reputation: 3325

Create a function that converts degrees to radians:

CREATE OR REPLACE FUNCTION degree_to_radian(p_degree IN NUMBER)
   RETURN NUMBER IS
BEGIN
   RETURN p_degree / 57.2957795;
END degree_to_radian;

Upvotes: 6

Related Questions