a.id不是主鍵,用關聯肯定有問題.

解决方案 »

  1.   

    pls try:   select W.id,W.ss,Q.ss from 
       (select a.id,sum(a.money) as ss  from a group by a.id having sum(a.money)<500) W ,
       (select b.id,sum(b.money) as ss from b group by b.id) Q 
        where W.id=Q.id
      

  2.   

    select a.id, sum(a.money),sum(b.money) from a left join b
    on a.id = b.id
    group by a.id
    having sum(a.money) < 500
      

  3.   

    同意 hjhing(winding)