日期:2014-05-17 浏览次数:20386 次
declare @sql nvarchar(1000) select @sql=isnull(@sql,'')+',max(case when dth='+rtrim(dth)+' then zzcj else 0 end)['+rtrim(dth)+']' from (select distinct dth from tb)t exec('select mh'+@sql+' from tb group by mh')