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!

Connect By Level Loop

ChoMan23Jan 3 2017 — edited Jan 3 2017

So I have the following query and when just 1 row is in the table I get the desired result, but when multiple rows are in the table I am getting an infinite loop and I do not know why. Any help would be greatly appreciated. Thank you.

SELECT      DEPT_ID,     

          RANK() OVER (PARTITION BY CASE WHEN ROWNUM <= ((24 + 2) * 6) * (1/6) THEN 1             

                    WHEN ROWNUM <= ((24 + 2) * 6) * (2/6) THEN 2              

                    WHEN ROWNUM <= ((24 + 2) * 6) * (3/6) THEN 3             

                    WHEN ROWNUM <= ((24 + 2) * 6) * (4/6) THEN 4             

                    WHEN ROWNUM <= ((24 + 2) * 6) * (5/6) THEN 5              

          ELSE 6 END ORDER BY rownum) as CENSUS    

FROM    APEX_DATA.NURSE_STAFFING_BUDGETED_CENSUS

WHERE  BUDGET_ID = 1347 CONNECT BY LEVEL <= (24 + 2) * 6

This post has been answered by Paulzip on Jan 3 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 31 2017
Added on Jan 3 2017
14 comments
1,750 views