pls explain connect by prior with example and its real time
use
Answers were Sorted based on User's Feedback
Answer / anil kumar karasi
sql>Select rownum,rownid,level,empno,ename from emp
connect by prior empno=mgr where mgr is null;
o/p
Rownum Rowid Level empno ename
------ ----- ----- ----- -----
1 AABBBCCDA 1 5678 abcd
2 AABBBCCDB 1 9087 poiu
3 AABBBCCDC 2 8567 QWER
4 AABBBCCDD 2 7321 LKJH
5 AABBBCCDE 3 1284 ZXCV
For more details go through this link
http://www.psoug.org/reference/connectby.html
Is This Answer Correct ? | 10 Yes | 1 No |
Connect by prior can be used to create heirarchical tree
structure
Is This Answer Correct ? | 6 Yes | 3 No |
Answer / simi
CONNECT BY PRIOR is used for tree-structured queries.
I found a simple & useful explanation here:
http://www.oraclepassport.com
SQL - CONNECT By PRIOR Section
Is This Answer Correct ? | 4 Yes | 2 No |
We need to compare two successive records of a table based on a field. For example, if the table is CUSTOMER, and the filed is Account_ID, To compare Account_IDs of record1 and record2 of CUSTOMER table, what can be the query ?
what is the difference between simple view and complex view?
Given two table employee and department EMP ---------------- empid deptid(fk) Dept --------------------- deptid(pk) deptname que-Write a query to find count of employee in each department. Expected Output- deptid countofEmployee --------------------------- 10 57 20 20 30 15
What is a tns service name?
how to get count of tables in particular database in Oracle?
What is not equal to in oracle?
How can I introduce multiple conditions in like operator?
waht is referencial integrity?
Is there any way to find out when one specific table/view/M-view is used last time. i.e. when one specific object is used in any SELECT statement.
what is load balancing and what u have used to do this?(sql loader)
What happens to the current transaction if the session is killed?
What is a sub query? Describe its types?