请教:邹建的遍历如何修改才能按如下顺序排列?
/*引用邹建的遍历
CREATE function f_GetChild(@id int)
returns @re table([id] int,[level] int,sid varchar(8000))
as
begin
declare @l int
set @l=0
insert @re select SubID,@l,right(10000+SubID,4)
from my_bbsPost where parentSubID=@id
while @@rowcount>0
begin
set @l=@l+1
insert @re select a.SubID,@l,b.sid+right(10000+a.SubID,4)
from my_bbsPost a,@re b
where a.parentSubID=b.[id] and b.[level]=@l-1
end
return
end
*/
示例树:
+7
|--20
|--14
| |--17
|
|--21
|--08
|--16
| |--22
|
|--09
|--12
|--18
|--19
现在要求每一层都按id的逆序排列该怎么办呢?
即f_GetChild(7)的结果要是:
21
20
14
17
08
16
22
09
12
18
19