January 2008
Intermediate to advanced
384 pages
8h 1m
English
The introduction of OLAP functions in Standard SQL made it possible to do all kinds of row numberings easily. I would like to stress that these are functions, and they behave like other SQL functions in spite of their strange syntax.
The ROW_NUMBER() OVER() is pretty simple to understand. The window clause works the same way. PARTITION BY creates partitions, just as it did with the aggregate functions. The ORDER BY clause sorts the rows within the partition and assigns a number from 1 to (n); if no ORDER BY clause is given, then the results are unpredictable. Since the ORDER BY applies to the whole partition, a RANGE clause makes no sense.
It does not make much sense to use a ROW_NUMBER() without ...
Read now
Unlock full access