Given a typical closure table, how would I write a query to get a list of ids back to the root? Is there a way to do that for all the [unique] ids? I'm using Microsoft SQL Server.
Given:
parent child depth
1 1 0
2 2 0
3 3 0
1 2 1
2 3 1
1 3 2
I'd like:
id path
1 1
2 1,2
3 1,2,3
Does that make sense?