行
AVG(pnum) OVER(PARTITION BYpolno ORDER BY createtime ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS pnum6 ---当前行+往后全部行
FROM windows_func;
结果:
polno |
createtime |
pnum |
pnum1 |
pnum2 |
pnum3 |
pnum4 |
pnum5 |
pnum6 |
P088888888888 |
2016/2/10 |
1 |
1 |
1 |
4.57142857 |
1 |
2 |
4.5714286 |
P088888888888 |
2016/2/11 |
3 |
2 |
2 |
4.57142857 |
2 |
1.666667 |
5.1666667 |
P088888888888 |
2016/2/12 |
1 |
1.66667 |
1.6667 |
4.57142857 |
1.666667 |
3.5 |
5.6 |
P088888888888 |
2016/2/13 |
9 |
3.5 |
3.5 |
4.57142857 |
3.5 |
3.4 |
6.75 |
P088888888888 |
2016/2/14 |
3 |
3.4 |
3.4 |
4.57142857 |
4 |
5.6 |
6 |
P088888888888 |
2016/2/15 |
12 |
4.83333 |
4.8333 |
4.57142857 |
6.25 |
5.6 |
7.5 |
P088888888888 |
2016/2/16 |
3 |
4.57143 |
4.5714 |
4.57142857 |
6.75 |
6.75 |
3 |
其它相似的函数就不举例了。