Declare @sql varchar(8000)
set @sql = 'select 日期,单号'
select @sql = @sql + ',sum(case 货名 when '''+货名+''' then 数量 else 0 end) ['+货名+']'
from (select distinct 货名 from aa) as a
select @sql = @sql+' from aa group by 日期,单号'exec(@sql)
set @sql = 'select 日期,单号'
select @sql = @sql + ',sum(case 货名 when '''+货名+''' then 数量 else 0 end) ['+货名+']'
from (select distinct 货名 from aa) as a
select @sql = @sql+' from aa group by 日期,单号'exec(@sql)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货