日期:2014-05-16 浏览次数:20679 次
declare @sql4 varchar(8000)
set @sql4='select ColorCode'
select @sql4=@sql4+',['+dd+']=Cast(sum(case Size when '''+dd+''' then (ActualQty-OrderQty)/OrderQty else 0 end) as Varchar(20))+''%'''
from (select distinct dd=Size from #c) ss Left Outer Join BSsizx on BSsizx.sizx=ss.dd Order by BSsizx.Seqno
set @sql4=@sql4+' ,Cast(4 As Varchar(1)) Status into ##a4 from #c group by ColorCode'
exec(@sql4)
declare @sql varchar(8000)
set @sql='select ColorCode'
select @sql=@sql+',['+dd+']=Cast(sum(case Size when '''+dd+''' then (OrderNoQty-ActualQty)/OrderNoQty else 0 end) as Varchar(10))+''%'''
from (select distinct dd=size from #c) ss
set @sql=@sql+' from #c group by ColorCode'
exec (@sql)