[quote]Originally posted by visakh16
SELECT owner,
[1] AS Occupant_1,
[2] AS Occupant_2,
[3] AS Occupant_3,
[4] AS Occupant_4,
[5] AS Occupant_5,
[6] AS Occupant_6
FROM
(
SELECT ROW_NUMBER() OVER (PARTITION BY owner ORDER BY (SELECT 1)) AS Rn,owner,[occupant type]
FROM table
)t
PIVOT(MAX([occupant type]) FOR Rn IN ([1],[2],[3],[4],[5],[6]))p
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
Thanks you.. That was just brilliant...!