Мне немного проще, если вы измените формат вашего набора данных.
declare @example table (
ExampleID int identity(1,1) not null primary key clustered
, SalesPerson nvarchar(255) not null
, AmountOfClient int not null
, SalesLastYear int not null
, ProjectedSales int not null
);
insert into @example (SalesPerson, AmountOfClient, SalesLastYear, ProjectedSales)
select 'Rob', 44, 200, 150 union all
select 'Bill', 28, 120, 100 union all
select 'Thomas', 60, 300, 320;
;with cte as (
select SalesPerson
, AmountOfClient as Metric
, 'Clients' as [Type]
from @example
union all
select SalesPerson
, SalesLastYear
, 'LastYear' as [Type]
from @example
union all
select SalesPerson
, ProjectedSales
, 'Projected' as [Type]
from @example
)
--select * from cte
select [Type]
, [Rob]
, [Bill]
, [Thomas]
from
(
select SalesPerson
, metric
, [type]
from cte
) source
pivot
(
max(Metric)
for SalesPerson in ([Rob], [Bill], [Thomas])
) as pvt;
Результирующий набор
Type Rob Bill Thomas
Clients 44 28 60
LastYear 200 120 300
Projected 150 100 320