update stuartlynn.chicago_gardens_1 set seg_10 = (
SELECT * from OBS_GetUSCensusCategory(
the_geom,
'Spielman-Singleton Segments: 10 Clusters')
)
WITH
n(cartodb_id,seg55) AS (
select cartodb_id, OBS_GetUSCensusCategory(
the_geom,
'Spielman-Singleton Segments: 55 Clusters')
FROM stuartlynn.chicago_gardens_1
)
UPDATE stuartlynn.chicago_gardens_1
SET seg_55=n.seg55
FROM n
WHERE n.cartodb_id = stuartlynn.chicago_gardens_1.cartodb_id
WITH
n(cartodb_id, total_pop, median_income, median_age) AS (
select cartodb_id,
OBS_GetUSCensusMeasure(the_geom, 'Total Population' ) as pop,
OBS_GetUSCensusMeasure(the_geom, 'Median Age' ) as age,
OBS_GetUSCensusMeasure(the_geom, 'Median Household Income in the past 12 Months' ) as income
where the_geom is not null
FROM stuartlynn.chicago_gardens_1
)
UPDATE stuartlynn.chicago_gardens_1
SET seg_55=n.seg55
FROM n
WHERE n.cartodb_id = stuartlynn.chicago_gardens_1.cartodb_id