anthonydb/practical-sql

missing "," in chapter 6

marcosfromrio opened this issue · 7 comments

"
➌ SELECT c2010.geo_name,
c2010.state_us_abbreviation AS state,
c2010.p0010001 AS pop_2010,
c2000.p0010001 AS pop_2000
c2010.p0010001 - c2000.p0010001 AS raw_change,
"

missing "," in line 4

im reading the book on learning.oreilly

Hello, @marcosroot -- thanks for letting me know. It seems that error is present in the Kindle version as well. However, the code is correct in the print copies and PDF versions. I will alert the publisher and hopefully they can provide an update to O'Reilly.

The section of this code (Listing 6-13) that states:

FROM us_counties_2010 c2010 INNER JOIN us_counties_2000 c2000

Is it missing "AS" for the aliases c2010 and c2000?

@anthonysim That line of code is correct as-is. Although you could insert AS before the table alias, it's not required. In fact, you can even omit AS when aliasing column names in queries.

Here's a good discussion for more: https://stackoverflow.com/questions/4164653/whats-the-purpose-of-sql-keyword-as

i read this book on O'Reilly (Media) plataform, maybe the version on the site is equal the kindle/pdf version

I think there must be other errors, because I read only until Chapter 7, if there is more I will comment here

I am apparently overthinking chapter 6 "try it yourself" # 2. The median() tells me the function can not be created for some reason. the percentile_cont will tell me there is not enough info. I am trying to manipulate the code, but it is not successful.

@lechter69
You're using the first edition of Practical SQL, and unfortunately a handful of the code examples in it will no longer work due to changes in PostgreSQL. The median() function is one of them -- it's no longer possible to create it as written.

Please paste the code you're using for percentile_cont() here. Also, you can always look at the Try It Yourself answers in this repo.