I will try to work something up but with out sample data it will take a little longer as i will need to generate some. As far as aggregating you can always aggregate a set of 1 (MAX(1) is 1)
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]