The GROUP BY Clause

The GROUP BY clause is intimately connected to aggregates. In fact, GROUP BY doesn't really have much use without aggregate functions: it divides a table into sets of rows, and aggregate functions produce summary values for each set. These values are called vector aggregates. (A scalar aggregate is a single value produced by an aggregate function as discussed in the previous chapter.) Figure 6.1 shows examples of scalar and vector aggregate queries.

Figure 6.1. Scalar and Vector Aggregates

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition 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.