1 Matching Annotations
- Nov 2020
-
help.looker.com help.looker.com
-
So far, all the grouping we've done is according to the unique values within a column or set of columns (using PARTITION BY). However, you can do even fancier things by making the group relative to each row. In other words, as SQL runs through each row, it will perform a calculation for the surrounding rows. This allows you to do things like get a sum for only the 5 previous rows. Here is a diagram that demonstrates which rows SQL will consider (in purple) when it reaches a given row (in aqua), if we tell it to look at the 5 previous rows:
-