Chapter 25

OLAP Aggregation in SQL

Abstract

Reports, also known as OLAP queries, mix unlike things into the same row or the same table. This is done for reporting rather than traditional queries.

Keywords

Online transaction processing

GROUP BY

OLAP

ROLLUP

CUBE

GROUPING(< column reference >) function

GROUPING SET

OVER()

ORDER BY

PARTITION BY

< null ordering >

ROWS

RANGE

UNBOUNDED PRECEDING

CURRENT ROW

BETWEEN

EXCLUDE

Ordinal functions

ROW_NUMBER()

RANK()

DENSE_RANK()

PERCENT_RANK()

CUME_DIST

LEAD

LAG

FIRST

LAST

FIRST_VALUE

LAST_VALUE

Most sql programmers work with OLTP (online transaction processing) databases and write simple, one-level aggregations. This chapter reviews how the usual GROUP BY clause works. The result set is partitioned ...

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