I am using the following query with PIVOT:
SELECT *
FROM (
SELECT
MEMBER_PROPERTY as [MEMBER_PROPERTY],MEMBER_VALUE as MEMBER_VALUE,
MEMBER_ID as MEMBER_ID
FROM MEMBER_ATTRIBUTES) as s
PIVOT
(
max(MEMBER_PROPERTY)
FOR [MEMBER_VALUE] IN (['My main interests'], traveling,accommodation, prizedraw)
)AS test
This query returns Null for "['My main interests'], traveling,accommodation, prizedraw" columns, i am not getting why, as the table has data for these columns for each record..
Please help me how can I get data.
UPDATE ::
I think this will help you.we should use QuoteName function for space column.