title: Month by Month Sales breakdown for top 10 Product for specific year Using Adventure Works Database in SQL Server
body: <p>This is what I used to find the top 10 products for 2013 by total sum of sales. What is the easiest way to get a monthly breakdown of sales for a specific product ID for the year?</p>
  <pre><code>SELECT TOP 10 
      sod.ProductID, prd.Name, SUM(LineTotal) AS SumOfSales
  FROM 
      Sales.SalesOrderDetail AS SOD
  JOIN 
      Sales.SalesOrderHeader AS SOH ON SOD.SalesOrderID = SOH.SalesOrderID
  JOIN
      Production.Product prd ON prd.ProductID = sod.ProductID
  WHERE 
      SOH.OrderDate &gt;= '01/01/2013' 
      AND SOH.OrderDate &lt;= '12/31/2013'
  GROUP BY 
      sod.ProductID, prd.Name
  -- HAVING SUM(LineTotal) &gt;= 2000000
  ORDER BY 
      SUM(LineTotal) DESC
  </code></pre>
  <p><a href="https://i.stack.imgur.com/0Gn1J.png" rel="nofollow noreferrer">Image of SQL output</a></p>
  <p>This is what I found after research but it says date_format is invalid</p>
  <pre><code>select date_format(sdate,'%M-%Y') as sdate,
  sum(LineTotal) as 'netsales',
  from Sales.SalesOrderDetail
  where ProductID=782 and ModifiedDate &gt;= '01/01/2013' and ModifiedDate &lt;= '12/31/2013'
  group by MONTH(sdate)
  order by MONTH(sdate);
  </code></pre>