Errata

SQL for Data Analysis

Errata for SQL for Data Analysis

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Page 43
4th code snippet

```
SELECT replace('$19.99','$','');
replace
-------
9.99
```

Just confirmed it, this query was return 19.99. I think the correct value 19.99, But the PDF describe 9.99. It is lost first character(1) maybe.

It confirmed using postgres 15.0 on docker (postgres:15.0-alpine3.16) .

```
postgres=# SELECT replace('$19.99','$','');
SELECT replace('$19.99','$','');
replace
---------
19.99
(1 row)
```

Note from the Author or Editor:
The leading "1" was dropped from the query output. This snippet should be changed from:

SELECT replace('$19.99','$','');
replace
-------
9.99

to:
SELECT replace('$19.99','$','');
replace
-------
19.99

TakesxiSximada  Nov 04, 2022 
Page 129
Tip/suggestion (lemur)

the date_part and age construction
date_part('year',age(b.term_start,a.first_term))
canĀ“t be fully replaced by function
datediff('year',first_term,term_start)
because when using DATEDIFF( ) the math is only really computed on the year value as exposed in towardsdatascience.com/using-sqls-datediff-for-age-dc0cb5b34190.

I reached the same result in the book with
datediff(day,a.first_term,b.term_start)/365

Note from the Author or Editor:
Change to read "... construction can be approximated by..."

In the same lemur tip box, the final line should have a closing parenthesis:
datediff(first_term,term_start,'year')

Alberto Cesar Tomelin  Mar 03, 2022