Merge branch 'master' of github.com:anthonydb/practical-sql-2

This commit is contained in:
anthonydb 2021-04-21 08:26:42 -04:00
commit 95bb5c2a98
3 changed files with 10 additions and 9 deletions

View File

@ -155,8 +155,7 @@ COPY nyc_yellow_taxi_trips (
improvement_surcharge, improvement_surcharge,
total_amount total_amount
) )
-- FROM 'C:\YourDirectory\nyc_yellow_taxi_trips.csv' FROM 'C:\YourDirectory\nyc_yellow_taxi_trips.csv'
FROM '/Users/adebarros/Dropbox/DataMonky/Book-Writing/PracticalSQL_2e/Code-Repo/Chapter_12/nyc_yellow_taxi_trips.csv'
WITH (FORMAT CSV, HEADER); WITH (FORMAT CSV, HEADER);
CREATE INDEX tpep_pickup_idx CREATE INDEX tpep_pickup_idx
@ -185,8 +184,7 @@ COPY
GROUP BY trip_hour GROUP BY trip_hour
ORDER BY trip_hour ORDER BY trip_hour
) )
-- TO 'C:\YourDirectory\hourly_taxi_pickups.csv' TO 'C:\YourDirectory\hourly_taxi_pickups.csv'
TO '/Users/adebarros/Desktop/hourly_taxi_pickups.csv'
WITH (FORMAT CSV, HEADER); WITH (FORMAT CSV, HEADER);
-- Listing 12-10: Calculating median trip time by hour -- Listing 12-10: Calculating median trip time by hour

View File

@ -96,8 +96,7 @@ CREATE TABLE crime_reports (
); );
COPY crime_reports (original_text) COPY crime_reports (original_text)
-- FROM 'C:\YourDirectory\crime_reports.csv' FROM 'C:\YourDirectory\crime_reports.csv'
FROM '/Users/adebarros/Dropbox/DataMonky/Book-Writing/PracticalSQL_2e/Code-Repo/Chapter_14/crime_reports.csv'
WITH (FORMAT CSV, HEADER OFF, QUOTE '"'); WITH (FORMAT CSV, HEADER OFF, QUOTE '"');
SELECT original_text FROM crime_reports; SELECT original_text FROM crime_reports;
@ -271,8 +270,7 @@ CREATE TABLE president_speeches (
); );
COPY president_speeches (president, title, speech_date, speech_text) COPY president_speeches (president, title, speech_date, speech_text)
-- FROM 'C:\YourDirectory\president_speeches.csv' FROM 'C:\YourDirectory\president_speeches.csv'
FROM '/Users/adebarros/Dropbox/DataMonky/Book-Writing/PracticalSQL_2e/Code-Repo/Chapter_14/president_speeches.csv'
WITH (FORMAT CSV, DELIMITER '|', HEADER OFF, QUOTE '@'); WITH (FORMAT CSV, DELIMITER '|', HEADER OFF, QUOTE '@');
SELECT * FROM president_speeches; SELECT * FROM president_speeches;

View File

@ -171,7 +171,7 @@ ORDER BY miles_from_dt ASC;
-- https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html -- https://www.census.gov/geo/maps-data/data/cbf/cbf_counties.html
-- Import -- Import (for use on command line if on macOS or Linux; see Chapter 18)
shp2pgsql -I -s 4269 -W LATIN1 tl_2019_us_county.shp us_counties_2019_shp | psql -d analysis -U postgres shp2pgsql -I -s 4269 -W LATIN1 tl_2019_us_county.shp us_counties_2019_shp | psql -d analysis -U postgres
-- Listing 15-13: Checking the geom column's well-known text representation -- Listing 15-13: Checking the geom column's well-known text representation
@ -245,6 +245,11 @@ WHERE ST_DWithin(sh.geom::geography,
-- https://www.census.gov/geo/reference/mtfcc.html -- https://www.census.gov/geo/reference/mtfcc.html
-- Here, H3010: A natural flowing waterway -- Here, H3010: A natural flowing waterway
-- Import (for use on command line if on macOS or Linux; see Chapter 18)
shp2pgsql -I -s 4269 -W LATIN1 tl_2019_35049_linearwater.shp santafe_linearwater_2019 | psql -d analysis -U postgres
shp2pgsql -I -s 4269 -W LATIN1 tl_2019_35049_roads.shp santafe_roads_2019 | psql -d analysis -U postgres
-- Listing 15-18: Using ST_GeometryType() to determine geometry -- Listing 15-18: Using ST_GeometryType() to determine geometry
SELECT ST_GeometryType(geom) SELECT ST_GeometryType(geom)