I have a set of data like this:
ID NAME PARENT
---- ------ -------
1 Obj #1 NULL
2 Obj #2 1
3 Obj #3 4
4 Obj #4 2
5 Obj #5 3
6 Obj #6 NULL
7 Obj #7 6
So if I wanted to get them with their oldest ancestor, I'd get results like this:
ID NAME OLDEST
---- ------ -------
1 Obj #1 NULL
2 Obj #2 1
3 Obj #3 1
4 Obj #4 1
5 Obj #5 1
6 Obj #6 NULL
7 Obj #7 6
How would I make a query to do this?