时间:2021-07-01 10:21:17 帮助过:1人阅读
示例1:
SELECT first_value(comm ) over() firstval, last_value(comm ) over() lastval, e.* FROM emp e
结果:
示例2:
SELECT first_value(comm ) over(partition by deptno) firstval, last_value(comm ) over(partition by deptno) lastval, e.* FROM emp e
结果:
示例3:
SELECT first_value(comm ) over(partition by deptno order by sal) firstval, last_value(comm ) over(partition by deptno order by sal) lastval, e.* FROM emp e
结果:
示例4:
SELECT first_value(comm ignore nulls) over(partition by deptno order by sal) firstval, last_value(comm ignore nulls) over(partition by deptno order by sal) lastval, e.* FROM emp e
结果:
示例5:
SELECT first_value(sal ignore nulls) over(partition by deptno order by sal) firstval, last_value(sal ignore nulls) over(partition by deptno order by sal) lastval, e.* FROM emp e; SELECT first_value(sal ignore nulls) over(partition by deptno order by sal) firstval, last_value(sal ignore nulls) over(partition by deptno order by sal ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) lastval, e.* FROM emp e
结果:
第一个sql结果:
第二个sql结果:
oracle first_value,last_valus
标签: