Probably the best tool for this is a dynamic cross-tab. Jeff Moden has an excellent article here[/url]. If after reading the article you are still having difficulty, post back.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden