写错了,最后结果应该是
主号    颜色    数量
1       aa      89
1       bb      34
1       cc      12
1       dd      23

解决方案 »

  1.   

    select min(主号), 颜色 , sum(数量)from  (select * from zs where 主号=1
           union all  
           select * from bj where 主号=1)  as UnionTbl
    group by 颜色
      

  2.   

    select min(主号), 颜色 , sum(数量)from  (select * from zs where 主号=1
           union select * from bj on zs.颜色=bj.颜色)  
    group by 颜色
      

  3.   

    select min(主号), 颜色 , sum(数量)from  (select * from zs where 主号=1
           union all  
           select * from bj where 主号=1)  as UnionTbl
    group by 颜色