日期:2014-05-18 浏览次数:21115 次
select '数量' as [BNAME], sum(case when day(OQCTime)=1 then Inspection else 0 end) as [1], 。。。。 sum(case when day(OQCTime)=31 then Inspection else 0 end) as [31] from TB
select '数量' as [BNAME], ltrim(sum(case when day(OQCTime)=1 then floor(Inspection) else 0 end)) as [1], ltrim(sum(case when day(OQCTime)=31 then floor(Inspection) else 0 end)) as [31] from TB WHERE .... union all select 'WPP' as [BNAME], ltrim(sum(case when day(OQCTime)=1 then WPP else 0 end)) as [1], ... ltrim(sum(case when day(OQCTime)=31 then WPP else 0 end)) as [31] from TB WHERE ....
------解决方案--------------------
--原理上就是这样的 select ltrim(1) union all select ltrim(4.5555) /* 1 4.5555 */