From b1c0a13dfce539105a4f003fa780acd0ca7243ff Mon Sep 17 00:00:00 2001 From: anthonydb Date: Fri, 15 May 2020 14:16:56 -0400 Subject: [PATCH] Minor updates to Chapters 2 and 3 code files. --- Chapter_02/Chapter_02.sql | 6 +++--- Chapter_03/Chapter_03.sql | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Chapter_02/Chapter_02.sql b/Chapter_02/Chapter_02.sql index ee2b6a2..4bd7c93 100644 --- a/Chapter_02/Chapter_02.sql +++ b/Chapter_02/Chapter_02.sql @@ -1,9 +1,9 @@ --------------------------------------------------------------- --- Practical SQL: A Beginner's Guide to Storytelling with Data +--------------------------------------------------------------------------- +-- Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition -- by Anthony DeBarros -- Chapter 2 Code Examples --------------------------------------------------------------- +---------------------------------------------------------------------------- -- Listing 2-1: Creating a database named analysis diff --git a/Chapter_03/Chapter_03.sql b/Chapter_03/Chapter_03.sql index d1d49bf..83c920d 100644 --- a/Chapter_03/Chapter_03.sql +++ b/Chapter_03/Chapter_03.sql @@ -1,9 +1,9 @@ --------------------------------------------------------------- --- Practical SQL: A Beginner's Guide to Storytelling with Data +--------------------------------------------------------------------------- +-- Practical SQL: A Beginner's Guide to Storytelling with Data, 2nd Edition -- by Anthony DeBarros -- Chapter 3 Code Examples --------------------------------------------------------------- +---------------------------------------------------------------------------- -- Listing 3-1: Querying all rows and columns from the teachers table @@ -96,6 +96,15 @@ FROM teachers WHERE school = 'F.D. Roosevelt HS' AND (salary < 38000 OR salary > 40000); +-- Note how the results change if we omit parentheses. That's +-- because the AND operator takes precedence over OR and is +-- evaluated first: + +SELECT * +FROM teachers +WHERE school = 'F.D. Roosevelt HS' + AND salary < 38000 OR salary > 40000; + -- Listing 3-10: A SELECT statement including WHERE and ORDER BY SELECT first_name, last_name, school, hire_date, salary