SQL行列转换
declare @sql varchar(4000) set @sql='select name' select @sql=@sql+',isnull(sum(case subject when '''+subject+''' then result end),0)['+subject+']' from (select distinct subject from CJ) as a select @sql=@sql+' from CJ group by Name' print @sql exec(@sql)
参考:http://www.cnblogs.com/iamzhanglei/archive/2009/12/27/1633356.html
更多前端内容请访问个人博客:殷路辉的个人博客