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!

ROWNUM with Model

Orcl ApexOct 18 2017 — edited Oct 19 2017

Hi All,

I am trying to fetch first 10 employees from hr schema employees table using Model clause but even after restricting number of iterations it showing all rows in result set.

SELECT * FROM employees

WHERE rownum < 10

ORDER BY employee_id;

SELECT

        *

  FROM

    employees

MODEL

DIMENSION BY(ROW_NUMBER() OVER( ORDER BY employee_id) AS rnk)

MEASURES(employee_id,CAST(NULL AS NUMBER) AS details)

RULES

    ITERATE(10) UNTIL (employee_id[ITERATION_NUMBER] = 10)

    (details[1] = employee_id[ITERATION_NUMBER+1]);

This post has been answered by Solomon Yakobson on Oct 18 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2017
Added on Oct 18 2017
7 comments
355 views