Skip to content

Instantly share code, notes, and snippets.

@voltgister
Created February 4, 2016 17:25
Show Gist options
  • Save voltgister/30b1ee262dd88910eb47 to your computer and use it in GitHub Desktop.
Save voltgister/30b1ee262dd88910eb47 to your computer and use it in GitHub Desktop.
-- Which regions have the highest density of devices?
-- Returns the top 5 regions and devices per m^2.
select r.id, count(*) / area(r.border) as device_density
from devices as d
inner join regions as r
on contains(r.border, d.location)
group by r.id
order by device_density desc
limit 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment