Minor edits during proofreading

This commit is contained in:
Anthony DeBarros 2021-09-28 21:40:36 -04:00
parent b5fbb1fe2b
commit df175c9a39
2 changed files with 9 additions and 6 deletions

View File

@ -79,7 +79,7 @@ SELECT ST_MPolyFromText('MULTIPOLYGON((
-- https://www.ams.usda.gov/local-food-directories/farmersmarkets -- https://www.ams.usda.gov/local-food-directories/farmersmarkets
-- Listing 15-8: Create and load the farmers_markets table -- Listing 15-8: Creating and loading the farmers_markets table
CREATE TABLE farmers_markets ( CREATE TABLE farmers_markets (
fmid bigint PRIMARY KEY, fmid bigint PRIMARY KEY,
@ -108,9 +108,10 @@ ALTER TABLE farmers_markets ADD COLUMN geog_point geography(POINT,4326);
-- Now fill that column with the lat/long -- Now fill that column with the lat/long
UPDATE farmers_markets UPDATE farmers_markets
SET geog_point = ST_SetSRID( SET geog_point =
ST_MakePoint(longitude,latitude)::geography,4326 ST_SetSRID(
); ST_MakePoint(longitude,latitude)::geography,4326
);
-- Add a spatial (R-Tree) index using GIST -- Add a spatial (R-Tree) index using GIST
CREATE INDEX market_pts_idx ON farmers_markets USING GIST (geog_point); CREATE INDEX market_pts_idx ON farmers_markets USING GIST (geog_point);
@ -193,7 +194,7 @@ FROM us_counties_2019_shp
ORDER BY gid ORDER BY gid
LIMIT 1; LIMIT 1;
-- Listing 15-15: Find the largest counties by area using ST_Area() -- Listing 15-15: Finding the largest counties by area using ST_Area()
SELECT name, SELECT name,
statefp AS st, statefp AS st,
@ -215,6 +216,7 @@ WHERE ST_Within(
); );
-- Listing 15-17: Using ST_DWithin() to count people near Lincoln, Nebraska -- Listing 15-17: Using ST_DWithin() to count people near Lincoln, Nebraska
SELECT sum(c.pop_est_2019) AS pop_est_2019 SELECT sum(c.pop_est_2019) AS pop_est_2019
FROM us_counties_2019_shp sh JOIN us_counties_pop_est_2019 c FROM us_counties_2019_shp sh JOIN us_counties_pop_est_2019 c
ON sh.statefp = c.state_fips AND sh.countyfp = c.county_fips ON sh.statefp = c.state_fips AND sh.countyfp = c.county_fips
@ -227,6 +229,7 @@ WHERE ST_DWithin(sh.geom::geography,
CREATE INDEX us_counties_2019_shp_geog_idx ON us_counties_2019_shp USING GIST (CAST(geom AS geography)); CREATE INDEX us_counties_2019_shp_geog_idx ON us_counties_2019_shp USING GIST (CAST(geom AS geography));
-- Listing 15-18: Displaying counties near Lincoln, Nebraska -- Listing 15-18: Displaying counties near Lincoln, Nebraska
SELECT sh.name, SELECT sh.name,
c.state_name, c.state_name,
c.pop_est_2019, c.pop_est_2019,

View File

@ -886,7 +886,7 @@ SELECT regexp_replace('Williams, Sr.', ', ', ' ');
SELECT (regexp_match('Williams, Sr.', '.*, (.*)'))[1]; SELECT (regexp_match('Williams, Sr.', '.*, (.*)'))[1];
-- 2. Using any one of the presidents' speeches addresses, count the number of -- 2. Using any one of the presidents' speeches, count the number of
-- unique words that are five characters or more. Hint: you can use -- unique words that are five characters or more. Hint: you can use
-- regexp_split_to_table() in a subquery to create a table of words to count. -- regexp_split_to_table() in a subquery to create a table of words to count.
-- Bonus: remove commas and periods at the end of each word. -- Bonus: remove commas and periods at the end of each word.