Generally column to rows or Rows to colums, use PIVOT method. You can include format on the query or after pivoting.
It may be easier and better to do formatting after pivoting, because pivoting itself is a costly operation and doesn't need to put more load on it.
Here is the Microsoft documentation of pivoting method
http://msdn.microsoft.com/en-us/library/ms177410.aspx[
^]