More Advanced Query Structures
Renée M. P. Teate · 2021
Structured Query Language (SQL) is a powerful way to shape and summarize data into a wide variety forms that can be used for many types of analyses. This chapter includes a few examples of more complex query structures. Using a UNION, the readers can combine any two queries that result in the same number of columns with the same data types. The columns must be in the same order in both queries. A self-join in SQL is when a table is joined to itself in order to compare rows to one another. The chapter demonstrates an example of that type of query using the Farmer's Market database by creating a report showing whether the total sales on each market date were the highest for any market to-date. It presents a summary of every market date attended by every customer, and determine their first purchase dates.