0

How do I calculate distance between two latitude, longitude points in miles using standard SQL without trigonometry?

LearningHero
  • 41
  • 2
  • 6
  • have you got an equation? – madoxdev Jan 12 '22 at 14:42
  • 2
    Please edit the question with db platform, and show data types – OldProgrammer Jan 12 '22 at 14:43
  • https://www.movable-type.co.uk/scripts/latlong.html – OldProgrammer Jan 12 '22 at 14:44
  • If you're using SQL Server, consider using the native geography data types. It makes it possible to query by distance and such. See https://learn.microsoft.com/en-us/sql/t-sql/spatial-geography/stdistance-geography-data-type?view=sql-server-ver15 – Adam Wise Jan 12 '22 at 15:23
  • I didn't find any standard SQL solution in the linked "duplicated by" answer... – jarlh Jan 12 '22 at 15:34
  • Is SO not about developing you own solution, and not asking for "can someone solve this for /me" ? The link with the duplicate show how to calculate the distance. this can be done in SQL too. (if enough info is provided in this question...) but you (@jarlh) are right, I should have linked this one: [SQL Distance Query without Trigonometry](https://stackoverflow.com/questions/6548940/sql-distance-query-without-trigonometry) – Luuk Jan 12 '22 at 15:46
  • @Luuk This is a duplicate, but a sql-specific answer is much more relevant and if it did not exist the one it was marked as a duplicate as is not sufficient in my mind: https://stackoverflow.com/questions/13026675/calculating-distance-between-two-points-latitude-longitude?rq=1 – Jason Goemaat Jan 12 '22 at 15:49

0 Answers0