with rpl(id,name,parentid,level) as(
select id,name,parentid,0
from g_person
where id = 0 and isactive = '1'--0:顶级
union all
select child.id,child.name,child.parentid,parent.level+1
from rpl parent,g_person child
where parent.id = child.parentid and child.isactive='1'
)
select * from rpl