select sum([number]) as sumnumber
from tabename
where subno in ('x1','y2')

解决方案 »

  1.   

    select No,subNo sum(Number)
    from table group by No,subNo
    ---------------------------
    ---------------------------
    不过你是要统计x1的总和、y2的总和还是(x1+y2)的总和呢...
      

  2.   

    是不是要
    select no,sum(Number) as Number
    from [table]
    group by no
      

  3.   

    是产品A
    需要半成品或原料
    x1,x2,y1,y2,y3等等
    现在要统计在表中A产品需要x1,y2数量的总和!
    谢谢!!!
      

  4.   

    也就是说在一个表(table)中如果存在下面的情况怎么查询
    表如下:
    No  subNo  Number
    A    x1      2
    A    x2      1
    ...   
    x2   y1      1
    x2   y2      3
    x2   y3      1
    ...
    B     x2     3
    B     x1     2
    C     y1     5
    ...
    假如现在要统计表中A产品中用到x1和y2的Number总和!!!
      

  5.   

    select sum(Number) from table where subno='x1' and No ='A'
    select sum(Number) from table where subno='y2' and No ='A'
    再加加看。
      

  6.   

    select sum(Number) as sumNumber from [table]
    where (subno='x1' or subno='y2') and No ='A'
      

  7.   

    不行啊,应该要用到逓归啊!
    如果那样的话,
    只能针对 no 是A 的统计啊!
      

  8.   

    select sum(number) as sunnumber from(select * from [table] where subno='x1' or subno='y2') where No='A'