Select t1.a ,sum(t2.b) as b from t1,t2 where t2.id=t1.id
group by t1.a

解决方案 »

  1.   

    select a,(select sum(b) from t2 where id=t1.id) b from t1
      

  2.   

    select a,(select sum(b) from t2 where id=t1.id) b from t1
    就这个了
      

  3.   

    select a,b from  t1,t2
      

  4.   

    select a,b from t1,t2 where t2.id=t1.id
      

  5.   

    ___________________________________________________________________________
    谢谢大家
    但是
    t2.b 是 varchar 类型哦___________________________________________________________________________
      

  6.   

    汇总下:
    select a,(select sum(b) from t2 where id=t1.id) b from t1或Select t1.a ,sum(t2.b) as b from t1,t2 where t2.id=t1.id
    group by t1.a呵呵!
    楼主结贴吧!
      

  7.   


    t2.b 是 varchar 类型哦
      

  8.   

    是字符型, cast 不了哦。