select sum(b.total) from a,b where a.id=b.id group by a.parent_id

解决方案 »

  1.   

    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
      

  2.   

    select a.PARENT_ID,sum(b.total) from a,b where a.id=b.id group by a.PARENT_ID
      

  3.   

    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
      

  4.   

    赞成 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