Id | Child_one_id | Child_two_id | Parent_id |
---|---|---|---|
1 | 2 | 3 | null |
2 | null | null | 1 |
3 | 2 | null | 1 |
4 | null | null | null |
5 | 6 | 7 | null |
6 | null | null | 5 |
7 | 6 | null | 5 |
8 | null | null | null |
9 | null | null | null |
10 | 11 | 12 | null |
11 | null | null | 10 |
12 | null | null | 10 |
I want sort order by in PostgreSQL as 10, 11,12,9,8,5,6,7,4,1,2,3 like Id descending , if that id contains child_one and parent_two then that will be followed as predecessor for that, all id’s have been linked in the table like that , parent id contains child_one and child_two, Child one contains null , null and parent_id ,but child_two contains child_one,null,parent_id , currently i am retriving only id in desc by using criteriBuilder in Java, so it is possible for crtieriaBuilder to acheieve this order by in Java
2