title: SQL Server Pivot table
body: <p>I need to make a pivot table. I have 3 columns (organization name, weekday (monday to sunday) and action (sell, buy, create, destroy etc)), how do I create a pivot table so that it would show counts of every action per organization for every week day?</p>
  
  <p>This is as close as I could get:</p>
  
  <pre><code>SELECT *
  FROM [AdventureWorksDW2012].[dbo].[Testine]
  PIVOT (COUNT (Tipas) 
         FOR Diena 
         IN 
         ([Monday],[Tuesday],[Wednesday],[Thursday],[Friday],[Saturday],[Sunday])) 
         AS KiekiaiPerDiena
  </code></pre>
  
  <p>It shows counts of total actions per organization for every day, so I basically need to expand to show counts per every action, not count of total actions.</p>