• Jeff Moden (11/16/2014)


    Careful now... If there are 3 column pairs for AirCraft and City, each pair of which is supposed to return a single row (i.e. 3 un-pivoted rows for each original row), then none of the queries above are correct because, in the presence of 1*10^6 original rows, the result set returns 9*10^6 rows instead of 3*10^6 rows.

    While that may be what you intended, it's not the solution for the given problem.

    Absolutely right, the last code example is not a correct solution to the problem, it's a comparison of two unpivoting/transposing methods.

    😎