Я сделал все, что мог, основываясь на вашем отредактированном операторе SQL.Вам просто нужно сгруппировать по отделам и типам, а затем агрегировать сводные значения
select case when [REDACTED] END as Dept, Type, max([2019W01]) as [2019W01], max([2019W02]) as [2019W02], max([2019W03]) as [2019W03], max([2019W04]) as [2019W04]
from ( select
ltrim(rtrim(Plant)) as Plant
,cast(ltrim(rtrim(WeekNo)) as varchar) as WeekNo
,substring(cast(ltrim(rtrim(WeekNo)) as [REDACTED]
from [REDACTED] ) as a
unpivot
(Value for Type in (A,B,C)) as sq
pivot (
min(Value)
for WeekNo in ([2019W01], [2019W02], [2019W03], [2019W04])
) as Pvt
group by Dept, Type