title: SQL query to get product sales by category for each month
body: <p>Hi i am looking for a query to get sales for each products category for each month</p>
  
  <p>i have 2 categories </p>
  
  <pre><code>Catid CatName
  1     Dispenser
  2     Refill
  </code></pre>
  
  <p>i used this below query to get total sales for all products categories</p>
  
  <pre><code>SELECT YEAR(OrderDate) as [Sales Year],
  MONTH(OrderDate) as [Sales Month],
  SUM(TotalAmount) AS [Total Sales]
  FROM Orders
  GROUP BY YEAR(OrderDate), MONTH(OrderDate)
  ORDER BY YEAR(OrderDate), MONTH(OrderDate)
  </code></pre>
  
  <p>out put for above query</p>
  
  <pre><code>Sales Year  Sales Month        Total Sales  
  2015            6              1000.00  
  2015            7              2000.00  
  </code></pre>
  
  <p>how can i get total sales for each product category </p>
  
  <p>out put should be like this</p>
  
  <pre><code>   Sales Year   Sales Month        Dispenser-sales      Refill-sales         
      2015            6              500.00                 500.00      
      2015            7              500.00                 1500.00 
  </code></pre>
  
  <p>my schema</p>
  
  <p><a href="https://i.stack.imgur.com/gFBwS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gFBwS.png" alt="Schema"></a></p>