forked from Weitzman-MUSA-GeoCloud/assignment02
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery02.sql
More file actions
30 lines (28 loc) · 770 Bytes
/
Copy pathquery02.sql
File metadata and controls
30 lines (28 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
with septa_bus_stop_blockgroups as (
select
stops.stop_id,
bg.geoid
from septa.bus_stops as stops
inner join census.blockgroups_2020 as bg
on st_dwithin(stops.geog, bg.geog, 800)
where bg.geoid like '42101%'
),
septa_bus_stop_surrounding_population as (
select
s.stop_id,
sum(p.total) as estimated_pop_800m
from septa_bus_stop_blockgroups s
inner join census.population_2020 p
on s.geoid = p.geoid
group by s.stop_id
)
select
stops.stop_id,
stops.stop_name,
pop.estimated_pop_800m
from septa_bus_stop_surrounding_population pop
inner join septa.bus_stops stops
on pop.stop_id = stops.stop_id
where pop.estimated_pop_800m > 500
order by pop.estimated_pop_800m asc
limit 8;