SqlServer根据经纬度排序

decimal LongGps = queryParam.Get<decimal>("LongGps");//经度
decimal LatGps = queryParam.Get<decimal>("LatGps");//纬度
                                                                                                                                                           
var orderBy= $"Order by  ACOS(SIN({LatGps} * PI() / 180) * SIN(a1* PI() / 180) + COS({LatGps} * PI() / 180) * COS(a1* PI() / 180) * COS({LongGps} * PI() / 180 - b1* PI() / 180)) * 6378.14 ASC";

a1=数据库存的纬度
b1=数据库存的经度

原文地址:https://www.cnblogs.com/smile-live/p/12502481.html