Friday, 9 August 2013

How to pivot SQL table to three columns showing every combination

How to pivot SQL table to three columns showing every combination

Using SQL Server 2008, and this completely imaginary scenario and data,
can anyone tell me how to transpose this (incomplete) database table:

The final table should contain every Town in its City and every
combination of thee (different) animals associated with that town and
city.

I have been considering a pivot but cant find a solution that will solve
this particular problem.
Hopefully someone can answer and help me understand the concept, which I
can apply to my real data which is a bit more complex.

No comments:

Post a Comment