Home » SQL & PL/SQL » SQL & PL/SQL » Pleaseeeeeeeeeee help me, its quite urgent
Pleaseeeeeeeeeee help me, its quite urgent [message #19160] Mon, 04 March 2002 00:12 Go to next message
Gilbey
Messages: 87
Registered: March 2002
Member
do anybody have got any idea about hierarchial query?
Its quite urgent.Please provide details about it?
Can anyone explain this query??

select level, max(sal) from emp
where level=2
connect by prior sal > sal
group by level;

Please help me out, urgently in need
Re: Pleaseeeeeeeeeee help me, its quite urgent [message #19167 is a reply to message #19160] Mon, 04 March 2002 03:26 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
If a table contains hierarchical data, you can select rows in a hierarchical order using
the hierarchical query clause:
# START WITH specifies the root row(s) of the hierarchy.
# CONNECT BY specifies the relationship between parent rows and child rows of
the hierarchy. Some part of conditionmust use the PRIOR operator to refer to
the parent row.
# WHERE restricts the rows returned by the query without affecting other rows of
the hierarchy.

Oracle uses the information from the hierarchical query clause clause to form the
hierarchy using the following steps:
1. Oracle selects the root row(s) of the hierarchy—those rows that satisfy the
START WITH condition.
2. Oracle selects the child rows of each root row. Each child row must satisfy the
condition of the CONNECT BY condition with respect to one of the root rows.
3. Oracle selects successive generations of child rows. Oracle first selects the
children of the rows returned in step 2, and then the children of those children,
and so on. Oracle always selects children by evaluating the CONNECT BY
condition with respect to a current parent row.
4. If the query contains a WHERE clause, Oracle eliminates all rows from the
hierarchy that do not satisfy the condition of the WHERE clause. Oracle evaluates
this condition for each row individually, rather than removing all the children
of a row that does not satisfy the condition.
Previous Topic: TRIGGER
Next Topic: drop user username cascade just hangs..
Goto Forum:
  


Current Time: Fri Mar 29 02:55:35 CDT 2024