Skip to content
Advertisement

Correspondence between two tables

I have table the table code_Commune contains gps for the city in general code_Commune:

Now I need to do correspondence with the table lead to add code_commune and Nom_Commune:

Table lead

Is there any way to do correspondence between the two tables?

Advertisement

Answer

You can find the closest city using some sort of distance measure. First, fix your first table:

Then you can use apply, once you decide on a distance metric. The following uses Manhattan distance:

This is highly inefficient. If you need efficiency, then you should be looking into SQL Server’s support for spatial data.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement