Analytic Query
Examples of common use cases are:
Calculate the “duration” of a web page view by LEADing 1 row ahead and determining how many seconds the user was on this page.
While it is not mandatory to specify a group, it can be useful for certain cases. If you create a group (made up of one or more fields), then the “lead forward / lag backward” operations are made only within each group. For example, suppose you have this:
And you want to create a field named Z, with the Y value in the previous row.
If you only care about the Y field, you don’t need to group. And you will have the following result:
But if you don’t want to mix the values for aaa and bbb, you can group by the X field, and you will have this: