试试这个;)
select ancestor_id as userid, sum(b.price) as totalfrom webineh_prefix_nodes_paths_tmp a join webineh_prefix_nodes_tmp b on b.userid = a.descendant_idwhere a.ancestor_id in (select userid from webineh_prefix_nodes_tmp where parent = 1)group by ancestor_id
已编辑
select ancestor_id as userid, sum(b.price) as totalfrom webineh_prefix_nodes_paths_tmp a join webineh_prefix_nodes_tmp b on b.userid = a.descendant_idinner join webineh_prefix_nodes_tmp con a.ancestor_id = c.useridand c.parent = 1group by ancestor_id



