select a.PARENT_ID,sum(b.total) from a,b where a.id=b.id group by a.PARENT_ID order by a.PARENT_ID
select a.PARENT_ID,sum(b.total) from a,b where a.id=b.id group by a.PARENT_ID
select c.id,sum(c.total) from (select a.id as id ,a.parent_id as parent_id,b.total as total from a,b where a.parent_id = b.id) c group by c.id
赞成 progrose(编程小子) 的做法;qiaozhiwei(乔)的写法是否要改为:select c.parent_id,sum(c.total) from (select a.parent_id as parent_id,b.total as total from a,b where a.id = b.id) c group by c.parent_id order by c.parent_id
order by a.PARENT_ID
from
(select a.id as id ,a.parent_id as parent_id,b.total as total from a,b where a.parent_id = b.id) c
group by c.id
from
(select a.parent_id as parent_id,b.total as total from a,b where a.id = b.id) c
group by c.parent_id order by c.parent_id