select 班次, 设备名称, 重量, 品位, 金属量 from 表 where 日期 = convert(char(10), getdate(), 120) order by 班次, 设备名称
union all
select '合计', 设备名称, sum(重量), sum(品位), sum(金属量) from 表 where 日期 = convert(char(10), getdate(), 120) 
 groupy by 设备名称

解决方案 »

  1.   

    select '累计'+班次, 设备名称, sum(重量), sum(品位), sum(金属量) from 表  
     groupy by 班次, 设备名称
      

  2.   

    select '累计'+班次, 设备名称, sum(重量), sum(品位), sum(金属量) from 表  
     groupy by 班次, 设备名称
      

  3.   

    1、
    select 班次,设备名称,重量,品位,金属量 from 其中一表 order by 班次,设备名称
    union all
    select '合计',设备名称,重量,品位,金属量 from 其中一表 group by 班次2、
    select 班次,设备名称,sum(重量) 重量,sum(品位)+(select sum(品位) from 其中一表 where datediff(day,时间列,getdate())=1 and 班次=tem.班次 and 设备名称=tem.设备名称) 品位,sum(金属量) 金属量 from 其中一表 tem where datediff(day,时间,getdate)=0 group by 班次,设备名称