Chapter 4

Ordering, Calculating,and Grouping inQueries

4.1    The Keyword DISTINCT

Not only is the information retrieved from a database important, but how the results are presented to users is also important. Although tables themselves are not allowed to have duplicate rows, query results can easily contain duplicates. Suppose you ran Example Query 4-1.

 

images

The output of Example Query 4-1 would start as shown in the Example Query 4-1 Results. There would be as many rows in the results as appear in the RoleQuote table. Because individual roles can have more than one quote, the query results would include duplicate roleID values.

Example Query ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.