ID grp find
534-1 A OK
534-1 A Good
534-1 B Good
534-1 C OK
534-2 A AVERAGE
I wanted to display above table using pivot, It should display all value from above table like this
ID A B C
534-1 OK Good OK
534-1 Good NULL NULL
534-2 Average NULL NULL
I'm using following query
select *
from
#temp1
pivot(MAX(find)
for grp in ([A]
,[B]
,[C])) pvt
But, I'm getting following output, which is missing another value for 534-1
.
ID A B C
534-1 OK Good OK
534-2 Average NULL NULL
Anyone have any idea what am I missing here ?
Please try:
select ID,[A],[B],[C]
from(
select *,row_number() over (partition by grp order by grp) Col from #temp1
)x pivot
(MAX(find)
for grp in ([A]
,[B]
,[C])) as y
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments