title: Database AdventureWorks
body: <p>I am trying to build the following query in AdventureWorks:</p>
  
  <p>What portions of our sales in each year (sale value) are related to individual customers and what portions of it goes for stores? The result columns should be as follow and should be sorted by year:</p>
  
  <pre><code>Year, Percents of sale to Individuals, Percents of sale to stores, Total value of sale
  </code></pre>
  
  <p>Any idea how?</p>
  
  <p>This is what I've done so far just for individuals and I'm not sure if its correct.</p>
  
  <pre><code>   SELECT
     c.CustomerType,
     YEAR(oh.OrderDate) AS 'Year',
     SUM(od.LineTotal) AS 'Sale in year'
  
     FROM Sales.SalesOrderDetail od 
     INNER JOIN Sales.SalesOrderHeader oh ON od.SalesOrderID = oh.SalesOrderID
     INNER JOIN Sales.Customer c ON oh.CustomerID = c.CustomerID
  
     GROUP BY
     YEAR(oh.OrderDate),
     c.CustomerType 
  
     ORDER BY YEAR(oh.OrderDate) ASC
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/k7FEX.png" rel="nofollow">This is the output. I just don't know how to reach that<br>
      Year, Percents of sale to Individuals, Percents of sale to stores, Total value of sale</a></p>