I have a large table that has 8 row numbers with an associated loss and carrier. I am trying to convert into a horizontal structure.
CREATE TABLE #mytable ( [ID] int NULL, [RowNum] bigint NULL, [Loss] float NULL, [Carrier] nvarchar(255) NULL ) INSERT INTO #mytable ([ID], [RowNum], [Loss], [Carrier]) VALUES (1,1, 0, 'test1'), (1,2, NULL, 'test2'), (1,3, 1.95, 'test3'), (1,4, 51, 'test4'), (1,5, 105.75, 'test5'), (1,6, 0, 'test6'), (1,7, 173, 'test7'), (1,8, 256.35, 'test8'), (2,1, 33158.3, 'test1'), (2,2, 7925396, 'test2'), (2,3, 0, 'test3'), (2,4, NULL, 'test4'), (2,5, 2461684, 'test5'), (2,6, 159392, 'test6'), (2,7, 14791, 'test7'), (2,8, 14555, 'test8'); I am trying to get a horizontal table like the following (per id and a horizontal structure for Loss and Carrier):

I was trying case when end statements, but I wasn't achieving the desired results.
Can someone please help? I appreciate it.