Please search before posting.
What you're trying to do is called "pivot" there are many examples of this, here and on other sites.
For instance, Joe Fuda's site: http://www.sqlsnippets.com/en/topic-11716.html, scroll down to "rows to column".