欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Sql根据经纬度算出距离

程序员文章站 2022-04-19 19:44:34
SELECT ISNULL((2 * 6378.137 * ASIN(SQRT(POWER(SIN((117.223372- ISNULL(Latitude,0) )*PI()/360),2)+COS(117.223372*PI()/180)*COS(117.223372*PI()/180)*POW ......

SELECT  ISNULL((2 * 6378.137 * ASIN(SQRT(POWER(SIN((117.223372- ISNULL(Latitude,0) )*PI()/360),2)+COS(117.223372*PI()/180)*COS(117.223372*PI()/180)*POWER(SIN((117.223372- ISNULL(Longitude,0) )*PI()/360),2)))),0)   AS Distance  FROM RequirementOrder r where r.RequirementOrderID not in (SELECT O.RequirementOrderID from OrdersDetail O)