-
Book Overview & Buying
-
Table Of Contents
SQL for Data Analytics - Third Edition
By :
In Chapter 2, The Basics of SQL for Analytics, you learned how to perform operations with a single table. But what if you need data from two or more tables? In this section, you will assemble data in multiple tables using joins and unions.
Most of the time, the data you are interested in is spread across multiple tables. A simple SELECT statement over one table will not be enough to get you what you need. Fortunately, SQL has methods for bringing related tables together using the JOIN keyword.
To illustrate, look at two tables in the ZoomZoom database—dealerships and salespeople.
Figure 3.1: Structure of dealerships table
And the salespeople table looks like this:
Figure 3.2: Structure of salespeople table
In the salespeople table, you can observe that there is a column called dealership_id. This dealership_id column is a direct reference to the dealership_id column...