Oracle 中的经纬度距离计算查询

2021-12-30 00:00:00 oracle11g oracle

我有一个 Oracle 11g 数据库.我存储纬度和经度(比如商店或商店).现在我需要一个查询来计算商店和我的位置之间的距离(我将在查询中提供).我之前在 MySQL 中做过这个,但是在 Oracle 中没有 Radians 函数.所以我需要在 Oracle SQL 中工作.

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.

感谢帮助.谢谢.

推荐答案

创建一个将度数转换为弧度的函数:

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;

相关文章