Having trouble with data, code, or exercises in Practical SQL, 2nd Edition? I'm glad to help. Please answer these questions, and I'll typically reply within one to two business days.
Please include the chapter number in your issue title. For example: "Chapter 13: Regular Expression Question"
General
Please answer all of these as they're essential for troubleshooting.
What's your operating system (e.g. Windows 10, macOS Monterey, Ubuntu, etc.)?
Windows
Did you install PostgreSQL, PostGIS and pgAdmin according to the steps in Chapter 1? If not, please describe your installation (e.g., using RDS on Amazon Web Services).
Yes
Which versions of PostgreSQL and pgAdmin 4 are you using? If you aren't sure, for PostgreSQL run the SQL command SELECT version(); and for pgAdmin 4, navigate to "About pgAdmin 4" under the "Help" menu.
PostgreSQL 16, pgAdmin 7.2
Did you download the book's code examples and data from GitHub using the directions in Chapter 1? If not, please describe how you loaded the material on your computer.
Yes
Issue or Question
Chapter, page and code listing number:
Chapter 7, page 112 and 113.
Describe the issue or your question:
in the table us_counties_pop_est_2010 you are creating 2 columns with wrong data type, state_fips and county_fips as text.
When you try to run the SELECT from page, you get this error:
ERROR: operator does not exist: integer = text
LINE 10: ON c2019.state_fips = c2010.state_fips
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 444
Changing the last part of the SELECTION to CAST to integer, makes it to work:
FROM us_counties_pop_est_2019 AS c2019
JOIN us_counties_pop_est_2010 AS c2010
ON c2019.state_fips = c2010.state_fips::int
AND c2019.county_fips = c2010.county_fips::int
ORDER BY pct_change DESC;
Having trouble with data, code, or exercises in Practical SQL, 2nd Edition? I'm glad to help. Please answer these questions, and I'll typically reply within one to two business days.
Please include the chapter number in your issue title. For example: "Chapter 13: Regular Expression Question"
General
Please answer all of these as they're essential for troubleshooting.
What's your operating system (e.g. Windows 10, macOS Monterey, Ubuntu, etc.)?
Windows
Did you install PostgreSQL, PostGIS and pgAdmin according to the steps in Chapter 1? If not, please describe your installation (e.g., using RDS on Amazon Web Services).
Yes
Which versions of PostgreSQL and pgAdmin 4 are you using? If you aren't sure, for PostgreSQL run the SQL command
SELECT version();and for pgAdmin 4, navigate to "About pgAdmin 4" under the "Help" menu.PostgreSQL 16, pgAdmin 7.2
Did you download the book's code examples and data from GitHub using the directions in Chapter 1? If not, please describe how you loaded the material on your computer.
Yes
Issue or Question
Chapter, page and code listing number:
Chapter 7, page 112 and 113.
Describe the issue or your question:
in the table us_counties_pop_est_2010 you are creating 2 columns with wrong data type, state_fips and county_fips as text.
When you try to run the SELECT from page, you get this error:
ERROR: operator does not exist: integer = text
LINE 10: ON c2019.state_fips = c2010.state_fips
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 444
Changing the last part of the SELECTION to CAST to integer, makes it to work:
FROM us_counties_pop_est_2019 AS c2019
JOIN us_counties_pop_est_2010 AS c2010
ON c2019.state_fips = c2010.state_fips::int
AND c2019.county_fips = c2010.county_fips::int
ORDER BY pct_change DESC;