这几句看不懂啊,select @sql = @sql + ',sum(case Subject when '''+Subject+''' then Result end) ['+Subject+']'是什么作用啊,为什么还要sumfrom (select distinct Subject from CJ) as a--这句我倒是可以看懂select @sql = @sql+' from test group by name'这句同楼上所说的,不怎么明白,希望赐教了