CUME_DIST is a bit special. It needs to either
1. remember a value for each peer group somewhere,
2. three cursors.
How to compute these?
1. The first pass needs to find how many rows are in the partition.
(Q: BTW, is it true that "any two-pass window function needs the first pass
only to find #rows in the partition"?)
2. On the second pass, we need
2.1 find how many peers are in the peer group (5 rows have a=20)
2.2 compute the value and set it for every peer member.
Possible ways to do step#2:
A: make it in two passes:
- first, let the first row of the group store #values in the group
- second, propagate this value to all group members.
B: Use two cursors.
- The front cursor reaches the end of the peer group, remembers how many values
it saw and then stays there.
- The back cursor walks through the peer group and updates the values.