Introduction |
|
xix | |
Chapter 1 Data Sources |
|
1 | (14) |
|
|
1 | (1) |
|
Tools for Connecting to Data Sources and Editing SQL |
|
|
2 | (1) |
|
|
3 | (4) |
|
Dimensional Data Warehouses |
|
|
7 | (2) |
|
Asking Questions About the Data Source |
|
|
9 | (2) |
|
Introduction to the Farmer's Market Database |
|
|
11 | (1) |
|
A Note on Machine Learning Dataset Terminology |
|
|
12 | (1) |
|
|
13 | (2) |
Chapter 2 The SELECT Statement |
|
15 | (16) |
|
|
15 | (1) |
|
The Fundamental Syntax Structure of a SELECT Query |
|
|
16 | (1) |
|
Selecting Columns and Limiting the Number of Rows Returned |
|
|
16 | (2) |
|
The ORDER BY Clause: Sorting Results |
|
|
18 | (2) |
|
Introduction to Simple Inline Calculations |
|
|
20 | (2) |
|
More Inline Calculation Examples: Rounding |
|
|
22 | (2) |
|
More Inline Calculation Examples: Concatenating Strings |
|
|
24 | (2) |
|
|
26 | (3) |
|
|
29 | (1) |
|
Exercises Using the Included Database |
|
|
30 | (1) |
Chapter 3 The WHERE Clause |
|
31 | (18) |
|
|
31 | (1) |
|
Filtering SELECT Statement Results |
|
|
32 | (2) |
|
Filtering on Multiple Conditions |
|
|
34 | (6) |
|
Multi-Column Conditional Filtering |
|
|
40 | (1) |
|
|
41 | (5) |
|
|
41 | (1) |
|
|
42 | (1) |
|
|
43 | (1) |
|
|
44 | (1) |
|
A Warning About Null Comparisons |
|
|
44 | (2) |
|
Filtering Using Subqueries |
|
|
46 | (1) |
|
Exercises Using the Included Database |
|
|
47 | (2) |
Chapter 4 CASE Statements |
|
49 | (12) |
|
|
50 | (2) |
|
Creating Binary Flags Using CASE |
|
|
52 | (1) |
|
Grouping or Binning Continuous Values Using CASE |
|
|
53 | (3) |
|
Categorical Encoding Using CASE |
|
|
56 | (3) |
|
|
59 | (1) |
|
Exercises Using the Included Database |
|
|
60 | (1) |
Chapter 5 SQL JOINs |
|
61 | (18) |
|
Database Relationships and SQL JOINs |
|
|
61 | (10) |
|
A Common Pitfall when Filtering Joined Data |
|
|
71 | (3) |
|
JOINs with More than Two Tables |
|
|
74 | (2) |
|
Exercises Using the Included Database |
|
|
76 | (3) |
Chapter 6 Aggregating Results for Analysis |
|
79 | (18) |
|
|
79 | (1) |
|
Displaying Group Summaries |
|
|
80 | (4) |
|
Performing Calculations Inside Aggregate Functions |
|
|
84 | (4) |
|
|
88 | (2) |
|
|
90 | (1) |
|
|
91 | (2) |
|
|
93 | (1) |
|
CASE Statements Inside Aggregate Functions |
|
|
94 | (2) |
|
Exercises Using the Included Database |
|
|
96 | (1) |
Chapter 7 Window Functions and Subqueries |
|
97 | (16) |
|
|
98 | (3) |
|
|
101 | (1) |
|
|
102 | (1) |
|
Aggregate Window Functions |
|
|
103 | (5) |
|
|
108 | (3) |
|
Exercises Using the Included Database |
|
|
111 | (2) |
Chapter 8 Date and Time Functions |
|
113 | (14) |
|
Setting datetime Field Values |
|
|
114 | (1) |
|
|
115 | (1) |
|
|
116 | (2) |
|
|
118 | (1) |
|
|
119 | (1) |
|
Date Functions in Aggregate Summaries and Window Functions |
|
|
119 | (7) |
|
|
126 | (1) |
Chapter 9 Exploratory Data Analysis with SQL |
|
127 | (16) |
|
Demonstrating Exploratory Data Analysis with SQL |
|
|
128 | (1) |
|
Exploring the Products Table |
|
|
128 | (3) |
|
Exploring Possible Column Values |
|
|
131 | (3) |
|
Exploring Changes Over Time |
|
|
134 | (1) |
|
Exploring Multiple Tables Simultaneously |
|
|
135 | (3) |
|
Exploring Inventory vs. Sales |
|
|
138 | (4) |
|
|
142 | (1) |
Chapter 10 Building SQL Datasets for Analytical Reporting |
|
143 | (16) |
|
Thinking Through Analytical Dataset Requirements |
|
|
144 | (5) |
|
Using Custom Analytical Datasets in SQL: CTEs and Views |
|
|
149 | (4) |
|
Taking SQL Reporting Further |
|
|
153 | (4) |
|
|
157 | (2) |
Chapter 11 More Advanced Query Structures |
|
159 | (14) |
|
|
159 | (4) |
|
Self-Join to Determine To-Date Maximum |
|
|
163 | (4) |
|
Counting New vs. Returning Customers by Week |
|
|
167 | (4) |
|
|
171 | (1) |
|
|
171 | (2) |
Chapter 12 Creating Machine Learning Datasets Using SQL |
|
173 | (18) |
|
Datasets for Time Series Models |
|
|
174 | (2) |
|
Datasets for Binary Classification |
|
|
176 | (13) |
|
|
178 | (3) |
|
Expanding the Feature Set |
|
|
181 | (4) |
|
|
185 | (4) |
|
Taking Things to the Next Level |
|
|
189 | (1) |
|
|
189 | (2) |
Chapter 13 Analytical Dataset Development Examples |
|
191 | (38) |
|
What Factors Correlate with Fresh Produce Sales? |
|
|
191 | (20) |
|
How Do Sales Vary by Customer Zip Code, Market Distance, and Demographic Data? |
|
|
211 | (6) |
|
How Does Product Price Distribution Affect Market Sales? |
|
|
217 | (12) |
Chapter 14 Storing and Modifying Data |
|
229 | (10) |
|
Storing SQL Datasets as Tables and Views |
|
|
229 | (3) |
|
Adding a Timestamp Column |
|
|
232 | (1) |
|
Inserting Rows and Updating Values in Database Tables |
|
|
233 | (3) |
|
|
236 | (1) |
|
|
237 | (1) |
|
|
238 | (1) |
Appendix Answers to Exercises |
|
239 | (16) |
Index |
|
255 | |