日期:2014-05-16 浏览次数:20518 次
Some analytic functions allow the windowing_clause
.
In the listing of analytic functions at the end of this section, the functions that allow the windowing_clause
are followed by an
asterisk (*)。--有些分析函数允许windowing_clause,在附录中,带*号的分析函数可以用windowing_clause,可以看到很多是聚合函数。
rows代表物理行,range代表逻辑偏移,我们来做下试验rows:
--unbounded preceding and unbouned following针对当前所有记录的前一条、后一条记录,也就是表中的所有记录
--unbounded:不受控制的,无限的
--preceding:在...之前
--following:在...之后
SELECT E.DEPTNO,
E.EMPNO,
E.ENAME,
E.SAL,
LAST_VALUE(E.SAL)
OVER(PARTITION BY E.DEPTNO
ORDER BY E.SAL
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) MAX_SAL
FROM EMP E;
DEPTNO EMPNO ENAME SAL MAX_SAL
---------- ---------- ---------- ---------- ----------
10 7934 MILLER 1300 5000
10 7782 CLARK 2450 5000
10 7839 KING 5000 5000
20 7369 SMITH 800 3000
20 7876 ADAMS 1100 3000