practical-sql icon indicating copy to clipboard operation
practical-sql copied to clipboard

missing "," in chapter 6

Open marcosfromrio opened this issue 7 years ago • 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

marcosfromrio avatar Dec 27 '18 14:12 marcosfromrio

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.

anthonydb avatar Dec 27 '18 16:12 anthonydb

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 avatar Jan 07 '19 03:01 anthonysim

@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

anthonydb avatar Jan 07 '19 13:01 anthonydb

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

marcosfromrio avatar Jan 09 '19 22:01 marcosfromrio

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

marcosfromrio avatar Jan 09 '19 22:01 marcosfromrio

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 avatar Jan 01 '24 17:01 lechter69

@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.

anthonydb avatar Jan 02 '24 11:01 anthonydb