日期:2014-05-17 浏览次数:20538 次
select ID,rodno,Operator ,TestTime,max([1]) [1],max([2]) [2],max([3]) [3],max([4]) [4] from 表 group by ID,rodno,Operator ,TestTime 或 select ID,rodno,Operator ,TestTime,sum([1]) [1],sum([2]) [2],sum([3]) [3],sum([4]) [4] from 表 group by ID,rodno,Operator ,TestTime
------解决方案--------------------
select id,rodno,operator,testime,sum(isnull ('1',0)) ,sum(isnull ('2',0)),sum(isnull ('3',0)),sum(isnull ('4',0)),sum(isnull ('5',0)) from 表 group by id,rodno,operator,testime
------解决方案--------------------
select ID, rodno, Operator, TestTime, sum(case [1] when null then 0 else [1] end)as [1] , sum(case [2] when null then 0 else [2] end)as [2] , sum(case [3] when null then 0 else [3] end)as [3] , sum(case [4] when null then 0 else [4] end)as [4] , sum(case [5] when null then 0 else [5] end)as [5] from TB group by ID, rodno, Operator, TestTime