Created
January 26, 2021 22:11
-
-
Save djouallah/936ead48525643b1abb334751526d3be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
xx AS ( | |
SELECT | |
"australia" AS key, | |
state, | |
suburbs, | |
longitude, | |
latitude, | |
IRSAD | |
FROM | |
`xxxxx.GIS.suburbs`) | |
SELECT | |
key, | |
xx.state, | |
xx.suburbs, | |
longitude, | |
latitude, | |
IRSAD, | |
100*ROUND(SQRT(POWER((lon2-longitude),2)+POWER((lat2-latitude),2)),2) AS dist, | |
IRSADREF | |
FROM | |
xx | |
LEFT JOIN ( | |
SELECT | |
"australia" AS dummy, | |
state, | |
suburbs AS ref, | |
IRSAD AS IRSADREF, | |
longitude AS lon2, | |
latitude AS lat2 | |
FROM | |
`xxxxx.GIS.suburbs` | |
WHERE | |
LOWER(suburbs) LIKE LOWER( @suburb ) | |
LIMIT | |
1) ss | |
ON | |
xx.key= ss.dummy | |
WHERE | |
100*ROUND(SQRT(POWER((lon2-longitude),2)+POWER((lat2-latitude),2)),2) < @distance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment