Instead of using PIVOT I'd rather go with CrossTab and DynamicCrossTab, since the code structure of PIVOT is kinda weird and it doesn't perform better than the CrossTab methods either.
I'd recommend to take a look at the CrossTab method referenced in my signature. Once you're familiar how it works you should read the DynamicCrossTab article.
As a side note: I've seen versions for dynamic Pivot on the web, too. And both will require using dynamic SQL.