Skip to Main Content

Oracle Database Discussions

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!

sorting which keeps the parent child structure

3288275Jul 31 2016 — edited Aug 1 2016

I have the following data in my database table.

rec_id        description        parent_id    ip_address        is_parent

100        Record 1        1000        80.160.4.5          1

101        child               1000        169.60.5.20        0

105        child               1000        169.60.5.20        0

103        Record 2        1002        80.160.4.3          1

104        child               1002        169.60.2.5          0

102        Record 3        1001        80.160.4.2          1

I want a sorting based on the column: ip_address of records where is_parent = 1

The parent record should be listed first and the corresponding child should list immediately after the parent.

The result should be as given below:

rec_id        description        parent_id    ip_address        is_parent

102        Record 3        1001        80.160.4.2          1

103        Record 2        1002        80.160.4.3          1

104        child               1002        169.60.2.5          0

100        Record 1        1000        80.160.4.5          1

101        child               1000        169.60.5.20        0

105        child               1000        169.60.5.20        0

Can anyone please help me to achievethe above result?

This post has been answered by AndrewSayer on Jul 31 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2016
Added on Jul 31 2016
5 comments
942 views