Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

Documentation bug in window_clause (missing parentheses)

Philipp SalvisbergDec 28 2023 — edited Dec 28 2023

The window_clause is documented in https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/SELECT.html#GUID-CFA006CA-6FF1-4972-821E-6996142A51C6__SECTION_XZB_MTC_4YB as follows:

According to the documentation, the following should work:

select ename,
       mgr,
       first_value(sal) over w as first,
       last_value(sal) over w as last,
       nth_value(sal, 2) over w as second,
       nth_value(sal, 4) over w as fourth
  from emp
window v as partition by deptno, w as v order by sal rows unbounded preceding;

However, this does not work, because parentheses are required around the window_specification like this:

select ename,
       mgr,
       first_value(sal) over w as first,
       last_value(sal) over w as last,
       nth_value(sal, 2) over w as second,
       nth_value(sal, 4) over w as fourth
  from emp
window v as (partition by deptno), w as (v order by sal rows unbounded preceding);

The documentation should be amended accordingly.

This post has been answered by Chris Saxon-Oracle on Jan 3 2024
Jump to Answer
Comments
Post Details
Added on Dec 28 2023
3 comments
208 views