select sum(每日的生产数量) 总和 from 表

解决方案 »

  1.   

    select sum(每日的生产数量) 总和 from 表 where 订单号列=@参数
      

  2.   

    select 订单号,sum(*) from tableName
    group by 订单号
    不知道是不是你想要得
      

  3.   

    表结构?!select 生产订单号,sum(1号)+sum(2号)+...+sum(31号) as 生产总和
    from 表
    group by 生产订单号
    where 生产的月份 between ... and ...
    and ...必须指出的是,从你的描述看,你的生产订单号并非主键,你的主键是:(生产订单号,生产的月份)
      

  4.   

    select 订单号,sum(每日的生产数量) from table
    group by 订单号
      

  5.   

    select 订单号,sum(*) as 总和
     from tableName
    group by 订单号
      

  6.   

    还漏了一些,
    主键是生产订单号+月份+年份,不过这不是重要的,每月的总和在表里有了,我要求的是根据每个订单号列出生产总和
    如:
    a号订单,1月生产100,2月生产100,总和200
    b号订单,3月生产100,4月生产100,总和200 不能用between,因为月份不确定,订单是随机来的 
      

  7.   

    select 定单号,
         sum(case when 月份=1 then 每日生产数量 else 0 end) as 月1,
         sum(case when 月份=1 then 每日生产数量 else 0 end) as 月2,
         ...
    from 表名
    group by 定单号