Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT STATMENT(USE CONNECT BY, PRIOR)

Status
Not open for further replies.

tkyap

Programmer
Sep 26, 2001
7
0
0
MY
HERE IS DATA IN KOK TABLE

ID Parent_ID Lev Name
1 1 AAA
2 1 2 AAB
3 1 2 AAD
4 1 BBB
5 1 2 AAC
6 5 2 BBC

RESULT I WANT

ID Parent_ID Lev Name
1 1 AAA
2 1 2 AAB
5 1 2 AAC
3 1 2 AAD
4 1 BBB
6 5 2 BBC

ANY BODY CAN HELP USE SINGLE SELECT STATEMENT TO SORT THE TABLE DATA

I TRY USE THE FOLLOWING SELECT STAEMENT, BUT THE RESULT IS NOT CORRECT:

SELECT * FROM KOK CONNECT BY PRIOR ID = PARENT_ID
START WITH LEV = 1
 
Have you tried using ORDER BY in your SELECT statement? It would look a little something like this -
SELECT * FROM
WHERE
ORDER BY COL1

By default the ORDER BY clause will use ascending order but this can be changed to descending by adding DESC at the end of ORDER BY i.e. ORDER BY DESC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top