Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- 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
You can’t perform that action at this time.