Forum Discussion

Tippelschniff175's avatar
Tippelschniff175
Copper Contributor
Mar 09, 2020

SQL - Distance to nearest premise using lat/long

Hi all, I am looking to create a function that i can then use on two tables. The first with UPRN (unique premise ref.), Latitude and Longitude coordinates and type A. The second identical but of type B.

 

I need a function that then lists, for each UPRN in table 1, the nearest UPRNs (in order of distance) from table 2. I have looked at using the Geography type but am unsure how to build it into a function that i can then use on table 1. Can anyone please help?

Resources