• While I couldn't agree more with Phil; this sort of operation doesn't belong in the database, I had to try find a way to do it without the UNION - I'm sure there are several ways to accomplish this though;

    (needs nicholasdoyle's constructing code)

    ;WITH CTE0 AS

    (

    SELECT Section

    ,NAME

    ,RowOrdering = ROW_NUMBER() OVER (ORDER BY Section, NAME)

    FROM #source

    GROUP BY Section, NAME

    WITH ROLLUP

    )

    SELECT VALUE= CASE WHEN NAME IS NULL THEN Section ELSE NAME END

    FROM CTE0 c

    WHERE Section IS NOT NULL

    ORDER BY RowOrdering