select 表1.user,A.* from (select no,sum(money2) from 表2 group by no 
union select no,sum(money3) from 表3 group by no) A 
inner join 表1 on  表1.no=A.no

解决方案 »

  1.   

    select a.no,a.usr,sum(b.money2),sum(c.money3)
    from 表1 a,表2 b,表3 c
    where a.no=b.no and b.no=c.no
    group by a.no,a.usr
      

  2.   

    select a.no,a.usr,sum(b.money2),sum(c.money3)
    from 表1 a left join 表2 b on where a.no=b.no left join 表3 c
    on a.no=c.no
    group by a.no,a.usr
      

  3.   

    select 表1.no,user,money2,money3 
    from 表1 inner join 
      (select 表2.no,Sum(money2) as money2,Sum(money3) as money3 
       from 表2 inner join 表3 on 表2.no=表3.no
       group by 表2.no) as AA
       on 表1.no=AA.no
      

  4.   

    楼上的,这样作还是会重复计算啊,而且用left join比较合适吧。
      

  5.   

    select t1.no,t1.user,t2.sm2,t3.sm3
    from 表1 t1 left join (select no,sum(money2) sm2 from 表2 group by no) t2 on t1.no=t2.no
    left join (select no,sum(money3) sm3 from 表3 group by no) t3 on t1.no=t3.no试试这样呢。
      

  6.   

    多谢大家,总于搞定了!!!
    不知道大家有什么sql编程方面书可以推荐一下,最好有很多实例的那种!!!