Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Analytic functions: FIRST vs FIRST_VALUE

vpolasaJul 7 2014 — edited Jul 8 2014

Hi,

  Can someone please help me understand difference between FIRST and FIRST_VALUE in Anaytic Functions.

I tried below 2 queries, but I'm seeing same output. The only difference I'm seeing is the SAL field is ordered in FIRST_VALUE, but not in FIRST.

SELECT ename,

  deptno,

  sal,

  MIN(sal) keep (dense_rank FIRST

ORDER BY sal) over (partition BY deptno) FIRST

FROM emp;

SELECT ename,

  deptno,

  sal,

  first_value(sal) over (partition BY deptno order by sal) FIRST

FROM emp;

Using: Windows 8.1

Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

PL/SQL Release 12.1.0.1.0 - Production

"CORE 12.1.0.1.0 Production"

TNS for 64-bit Windows: Version 12.1.0.1.0 - Production

NLSRTL Version 12.1.0.1.0 - Production

This post has been answered by Frank Kulash on Jul 7 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2014
Added on Jul 7 2014
4 comments
7,473 views