------解决方案-------------------- declare @sql varchar(1000) set @sql='select student_id' select @sql= isnull(@sql,'')+ ', sum( case subjectName when '''+ subjectName+''' then number else 0 end) as '''+subjectName+'''' From source group by subjectName select @sql=@sql+'From source group by student_id' exec(@sql) print @sql
------解决方案-------------------- C#方面报表,我也在学习中, 帮你顶顶先............
------解决方案--------------------
添加矩阵,我先以你的Tb_Score表为例: