Skip to content

Instantly share code, notes, and snippets.

@voltgister
Created January 26, 2016 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voltgister/45734a99e900c82c81cb to your computer and use it in GitHub Desktop.
Save voltgister/45734a99e900c82c81cb to your computer and use it in GitHub Desktop.
SELECT
n.name AS neighborhood_name,
SUM(m.kw) / AREA(r.border) AS kw_per_m2
FROM neighborhoods AS n
INNER JOIN meters AS m
ON CONTAINS(n.border, m.loc)
ORDER BY kw_per_m2 DESC
LIMIT 3
neighborhood_name kw_per_m2
----------------- ---------
Pawtucketville 1247.79
Belvidere 1004.37
Highlands 998.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment