PIVOT and UNPIVOT are built in functions in SQL 2005 but in sql2000 we can use case statement with group by clause to Achieve same thing
Example:
SELECT
Name,
MAX(CASE WHEN Title = 'Visit 1' then DateResult else null END) AS 'Visit1',
MAX(CASE WHEN Title = 'Visit 2' then DateResult else null END) AS 'Visit2'
FROM PersonSchedule
group
by Name
Example:
SELECT
Name,
MAX(CASE WHEN Title = 'Visit 1' then DateResult else null END) AS 'Visit1',
MAX(CASE WHEN Title = 'Visit 2' then DateResult else null END) AS 'Visit2'
FROM PersonSchedule
group
by Name
No comments:
Post a Comment