28

Grouping Operations

I am separating the partitions and grouping operations based on the idea that a group has group properties that we are trying to find, so we get a single row back for each group. A partition is simply a way of subsetting the original table, so we get a table back as a result.

28.1 GROUP BY Clause

The GROUP BY clause is based on simple partitions. A partition of a set divides the set into subsets such that (1) the union of the subsets returns the original set and (2) the intersection of the subsets is empty. Think of it as cutting up a pizza pie—each piece of pepperoni belongs to one and only one slice of pizza. When you get to the section on SQL-99 OLAP extensions, you will see “variation on a theme” in the ROLLUP and ...

Get Joe Celko's SQL for Smarties, 4th 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.