select sum(数量) from table where 物品='***'  group by 日期,站点

解决方案 »

  1.   

    或者
    select sum(数量) from table 
       select 数量 from table 
         where 物品='***'
       group by 日期,站点
      

  2.   

    还是不太懂你的意思,不过就我得理解不妨试试
    select sum(数量) from table group by ... where 物品='...'
      

  3.   

    简单说
    站点   物品   数量
    1      a     10
    1      b     10
    1      c     10
    2      a     20
    2      b     20
    2      c     20
    3      a     15
    3      b     15   
     
    我说的表1得到以下数据  30
                          60
                          30表2  物品=c          10
                         20现在想得到            10  30
                         20  60就这么简单
      

  4.   

    <1>
    insert into newtable(数量) select 数量 from table where 物品='***'
    <2>
    insert into newbable(sum数量) select sum(数量)from table group by 日期, 站点 where 物品<>'***'
      

  5.   

    不对啊,两个表的数据我都给出了sql语句,
    问题是如果合并成一个表,
    你的第二条语句就错了,sum()的值少了,
      

  6.   

    我用procedure做出来了,算了,没人会的