title: How to select rows to columns in SQL Server
body: <p>I don't know is it even possible to do without iterating cursors and filling temp tables. I have trouble to select data looking  like this:</p>
  
  <pre><code>+----------+-----------+-----------+
  |TypeName  | AlarmType | AlarmCount|
  +----------+-----------------------+
  |Antibody  | 1         | 2         |
  |Bacterium | 1         | 2         |
  |Bacterium | 3         | 2         |
  |CellLine  | 1         | 2         |
  +----------+-----------+-----------+
  </code></pre>
  
  <p>into result like this (there are 3 different AlarmType but 2 are listed):</p>
  
  <pre><code>+----------+-------+-------+-------+
  |TypeName  | Alarm1| Alarm2| Alarm3|
  +----------+-------+-------+-------+
  |Antibody  | 2     | 0     | 0     |
  |Bacterium | 2     | 0     | 2     |
  |CellLine  | 2     | 0     | 0     |
  +----------+-------+-------+-------+
  </code></pre>
  
  <p>As you can see, <code>AlarmCount</code> is now shown under corresponding <code>AlarmType</code> which is now column. If it isn't possible to do it, "you can't do it without cursors" its also a good answer.</p>
  
  <p><a href="http://sqlfiddle.com/#!6/5e57d/1" rel="nofollow">Here is my fiddle</a></p>