Hi @Vasily Zaytsev
Check this:
declare @T table(id int,type int, hrs int);
insert into @T values (1,1,5),(1,7,4),(2,1,3),(3,7,4)
select id,[1] as [hrs of type 1], [7] as [hrs of type 7]
from @T
pivot(max(hrs)for type in([1],[7]))p
select id
,max(case when type=1 then hrs end) as [hrs of type 1]
,max(case when type=7 then hrs end) as [hrs of type 7]
from @T
group by id
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.