• You need to have some way to order the original data.

    Here's your data set up so others can use it: -

    IF object_id('tempdb..#testEnvironment') IS NOT NULL

    BEGIN

    DROP TABLE #testEnvironment;

    END;

    SELECT id, col

    INTO #testEnvironment

    FROM (VALUES(1,'AppName'),(2,'AppVersion'),(3,'Product'),

    (4,'Date1'),(5,'Date2'),(6,'Date3'),

    (7,'AppName'),(8,'AppVersion'),(9,'Product'),

    (10,'Date1'),(11,'Date2'),(12,'Date3'),

    (13,'AppName'),(14,'AppVersion'),(15,'Product'),

    (16,'Date1'),(17,'Date2'),(18,'Date3')

    )a(id,col);

    Here's how to get your expected results: -

    SELECT

    MAX(CASE WHEN col = 'AppName' THEN id ELSE NULL END) AS AppName,

    MAX(CASE WHEN col = 'AppVersion' THEN id ELSE NULL END) AS AppVersion,

    MAX(CASE WHEN col = 'Product' THEN id ELSE NULL END) AS Product,

    MAX(CASE WHEN col = 'Date1' THEN id ELSE NULL END) AS Date1,

    MAX(CASE WHEN col = 'Date2' THEN id ELSE NULL END) AS Date2,

    MAX(CASE WHEN col = 'Date3' THEN id ELSE NULL END) AS Date3

    FROM #testEnvironment

    GROUP BY (id-1)/6;

    Note that because the "id" column is sequential, I've just grouped them into sixes by dividing by 6. You will need to provide more information about your data so that we can see how to achieve the same result for you - possibly a ROW_NUMBER ranking function?

    The results that the above produces is: -

    AppName AppVersion Product Date1 Date2 Date3

    ----------- ----------- ----------- ----------- ----------- -----------

    1 2 3 4 5 6

    7 8 9 10 11 12

    13 14 15 16 17 18


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/