a.c1是不是可以求和的数据类型?应该是select a.c2,sum(a.c1),b.c1 from a,b where a.c2=b.c1 group by a.c2  order by a.c2

解决方案 »

  1.   

    select sum(a.c1),a.c2 from a,b where a.c2=b.c1 group by a.c2  order by a.c2;这样才行
      

  2.   

    select sum(a.c1),a.c1 from a,b where a.c1=a.c2 and a.c1=b.c1 group by a.c1  order by a.c1
      

  3.   

    或:select sum(a.c1),b.c3 from a,b where a.c1=a.c2 and a.c1=b.c1 group by a.c1  order by a.c1
      

  4.   

    select sum(a.c1),b.c1 from a,b where a.c2=b.c1 group by a.c2,b.c1  order by a.c2
      

  5.   

    试:select b.c1 t.sum from b,(select sum(a.c1) as sum,a.c2 as c2 from a group by a.c2) t where b.c1=t.c2 order by t.c2
      

  6.   

    Lastdrop(空杯) :
    select sum(a.c1),b.c1 from a,b where a.c2=b.c1 group by a.c2,b.c1  order by a.c2为正解,关键是group by子句。