hi i am new to sql and face can't find salution for this.i want to diplay first the parant and then all it's subsequent children at different level, then second parant and all it's subsequent children , parent elements is null with levelid=1 i am using sql server 2000,and i don;t want to pass any root elemenet id, it should bring from start to end.
input
id name parentid levelid
1 a NULL 1
2 b 1 2
3 c 1 2
4 d 2 3
5 e 4 2
6 f NULL 1
7 g 6 2
8 h 7 3
i want the output like this
id name parentid levelid
1 a NULL 1
2 b 1 2
3 d 2 3
4 c 1 2
5 e 4 2
6 f NULL 1
7 g 6 2
8 h 7 3