Creating derived datasets
So far, you have been using SELECT queries to pull data from tables. You may have observed that the results of all SELECT queries are two-dimensional relations that look like the tables in a relational database. Knowing this, you may wonder whether there is some way to use the relations produced by the SELECT queries as if they were tables in your database. The answer is “yes.” You can simply take a query, insert it between a pair of parentheses, and give it an alias. The result of this is a relation that can be used in any other queries. This will help you build an analysis on top of an existing analysis, thus reducing errors and improving efficiency.
To illustrate, look at two tables in the sqlda database—dealerships and salespeople. Both the dealerships table and the salespeople table contain a column called dealership_id. This dealership_id column in the salespeople table is a direct reference to the dealership_id column in the...