我有一个入库单表:
ID         ProductID ProductName Volume      InDate
0405001     1001       aa         20      2004-04-09
0405002     1001       aa         30      2004-05-21
0405003     1002       bb         40     2004-05-21
现在想把不同单号的相同产品编号的数量相加放进库存表中
ID         ProductID   Volume
001        1001         50
002        1002         40
怎么操作?

解决方案 »

  1.   

    insert tblname (productid,volume) from select productid,count(volume) from tblOrder group by productid
      

  2.   

    select id,productid,sum(volume) from table group by volume
      

  3.   

    写错了
    select productid,sum(volume) from table group by productid
      

  4.   

    回复人: skytear() ( ) 信誉:100 
    insert tblname (productid,volume) from select productid,count(volume) from tblOrder group by productid
    服务器: 消息 156,级别 15,状态 1,行 1
    在关键字 'from' 附近有语法错误。
      

  5.   

    试试:
    insert into tblname (productid,volume) from select productid,sum(volume) as volume2 from tblOrder group by productid