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/prior/root

J2EE_LifeDec 6 2011 — edited Dec 8 2011
Hi All,

I am trying to understand CONNECT BY Level/prior/root. But i find it difficult to decipher what it actually does. I believe this is very useful method provided by oracle and can have multiple usages. can anyone please help me on this.

I googled about it but everywhere i could find only employee and manager problem, which will be solved by below query.
 SELECT employee_id, last_name, manager_id
   FROM employees
   CONNECT BY PRIOR employee_id = manager_id;
But if we just want query like below we can get the employee and its manage without CONNECT BY .
SELECT employee_id, last_name, manager_id
   FROM employees;
Other query is got for connect by is below, but couldn't understand it also:
 select SYSDATE-41 + level - 1 the_date
                            from dual
                          connect by level <= SYSDATE - SYSDATE-41 + 1
Please help me .

Edited by: J2EE_Life on Dec 6, 2011 8:12 AM
This post has been answered by Frank Kulash on Dec 6 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 5 2012
Added on Dec 6 2011
5 comments
1,986 views