PIVOTs need an aggregate function, because you could have multiple entries in the original table. If you know you only have one value per key, then just use MIN().
Also, '$row1', '$row2', '$row3' are now columns and need to be delimited like columns
select *
from (
select
name,propertyvalue, displayname
from indexrows
) a
PIVOT
(
MIN(propertyvalue)
for [displayname] in ([$row1], [$row2], [$row3])
) as pivot
No comments:
Post a Comment