Oracle分析函数之first()和last()函数

    select  deptno ,last_value(sal) over(order by deptno) first_sal,sal from emp;--order by分组有效


   select  deptno ,first_value(sal) over(order by deptno) first_sal,sal from emp;--order by分组无效


  select deptno,empno,first_value(sal)over(partition by deptno order by sal desc)as f ,sal from emp;--first会根据partition by分组,但是order不会分组


  select deptno,empno,last_value(sal)over(partition by deptno order by sal desc)as f ,sal from emp;--last会根据partition和order by分组

你可能感兴趣的:(Oracle之分析函数)