Chapter 5

Complex Queries andJoin Queries

5.1    Selection Queries with DISTINCT

Chapter 3 covered basic SQL queries using the keywords SELECT and WHERE. Chapter 4 introduced ordering, calculating, and grouping in queries. To keep the presentation of the new material in Chapter 4 straightforward, the examples did not include some of the features that had been introduced earlier in Chapter 3. Not all features of SQL can be combined in the same query, but the majority can. For example, you can easily use the keyword DISTINCT when writing a query that uses WHERE.

Suppose you wanted to find the distinct discountPrice values of movies that have won Academy Awards. Example Query 5-1 shows this query.


The complete output of Example Query 5-1 is ...

Get The SQL Programming Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.