insert into tb
select '部门1', '出勤率', '90分' union all
select '部门1', '领导满意度', '92分' union all
select '部门1', '工作效率', '95分' union all
select '部门2', '出勤率', '84分' union all
select '部门2', '领导满意度', '89分' union all
select '部门2', '工作效率', '93分'
go
declare @sql nvarchar(2000)
set @sql = ''
select @sql = @sql +',max(case when 列2=''' + 列2 +''' then 列3 else null end) as ['+列2+']'
from tb
group by 列2
set @sql = 'select 列1' + @sql + ' from tb group by 列1'