window的内包括:
(ROWS | RANGE) BETWEEN (UNBOUNDED | [num]) PRECEDING AND ([num] PRECEDING | CURRENT ROW | (UNBOUNDED | [num]) FOLLOWING)
(ROWS | RANGE) BETWEEN CURRENT ROW AND (CURRENT ROW | (UNBOUNDED | [num]) FOLLOWING)
(ROWS | RANGE) BETWEEN [num] FOLLOWING AND (UNBOUNDED | [num]) FOLLOWING
如何指定了order by,但是没有指定窗口,统计的数据是开始到当前行。
|---------------------------------------------------------------|
| SELECT a, SUM(b) OVER (PARTITION BY c ORDER BY d)
FROM T;
|
When ORDER BY is specified with missing WINDOW clause, the WINDOW specification defaults to RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
如果order by和 window都没有指定,那就是整个数据集
SELECT a, COUNT(b) OVER (PARTITION BY c, d)
FROM T;
When both ORDER BY and WINDOW clauses are missing, the WINDOW specification defaults to ROW BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.