日期:2014-05-18 浏览次数:20713 次
declare @sql varchar(8000) set @sql = 'select 商品编号 ' select @sql = @sql + ' , sum(case 帐户 when ''' + ltrim(帐户) + ''' then 数量 else 0 end) [' + ltrim(帐户) + ']' from (select distinct 帐户 from tb) as a set @sql = @sql + ' from tb group by 商品编号' exec(@sql)