Row to column Not column to row - Pivot 1 row to multiple columns using T SQL

23 Views Asked by At

I have data in a table that I want to pivot from 1 row to multiple columns. I only want the columns with dx to pivot if there is a value in them. Thanks.

This is a sample of what I have:

NBR dx dx2 dx3
11 j2 e4

This is what I want:

NBR Diag
11 j2
11 e4
0

There are 0 best solutions below