title: How to rotate a table horizontally in sql server
body: <p>i have table with columns as :</p>
  
  <pre><code>Sr.no  Subject  No of class attended    
  -------------------------------------
  1       English           3
  2       Maths             4
  3       SocialScience     5
  </code></pre>
  
  <p>I want the table in this format </p>
  
  <pre><code>English    Maths   SocialScience
  ---------------------------------
  3            4          5
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>Select case when subject ='Maths' then COUNT(No_of_Candidates) else null  end as Maths
  </code></pre>
  
  <p>but with this i get the data like this :</p>
  
  <pre><code> English    Maths   SocialScience
  ---------------------------------
     3            
                 4
                           5
  </code></pre>
  
  <p>Please help me how should i resolve this..</p>