title: Sql query to get total orders (count) by customer type
body: <p>I have 2 tables "Orders" and "Customers".</p>
  
  <p>I want to count number of orders according to customer type in each month, week and in each.</p>
  
  <p>Order table has orderid and CustomerIDfields.</p>
  
  <p>Customers table has CustomerID and CustomerTypeID field.</p>
  
  <p>I have tried below query :-</p>
  
  <pre><code>SELECT 
                  "Month" = month(o.OrderDate)
                   , "Year" = year(o.OrderDate)
                   , NoOfCustomer = Count(o.Total)                     
              FROM
                  Orders o        
                INNER JOIN 
                Customers C on C.CustomerID = o.CustomerID                          
              WHERE
                  o.OrderDate &gt;= convert(DATETIME, '1/1/2013 12:00:00 AM')
                  AND o.OrderDate &lt; convert(DATETIME, '12/31/2013 12:00:00 AM')
              GROUP BY
                  month(o.OrderDate)
                , year(o.OrderDate)
  
              ORDER BY
                  year(o.OrderDate)
                , month(o.OrderDate)
  </code></pre>
  
  <p>I want result something like below :-</p>
  
  <pre><code>Month   Year  NoOfCustomer CustomerType
  1       2013    45625         1
  2       2013    12131         2
  3       2013    54544         3
  4       2013    7888          4
  1       2013    5652          1
  2       2013    5655          2
  3       2013    5522          3
  4       2013    555           4
  </code></pre>
  
  <p>Thanks in advance.</p>