Assuming this table
ParentId ChildId SortOrder --------------------------------- 0 1 0 1 2 1 2 3
sounds almost identical to another I answered here You'll have to alter the order by a little.