By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Records: 9 Duplicates: 0 Warnings: 0
ID | ParentID |
---|---|
1 | 10 |
2 | 1 |
3 | 2 |
4 | 3 |
5 | null |
6 | 5 |
7 | 6 |
10 | 20 |
20 | null |
ID | MIN(PATH) |
---|---|
5 | 5 |
20 | 20 |
6 | 5 |
10 | 20 |
1 | 20 |
7 | 5 |
2 | 20 |
3 | 20 |
4 | 20 |