title: Finding the Weighted Average in a Query
body: <p>The question is:For the previous Track, compute the weighted average (instead of the average) average yield by nation (yield is defined as dividend divided by price, and is reported as a percentage). The weighted average includes the quantity of shares as a weight. 
  But I have no clue on how to find a weighted average.</p>
  
  <p>I already have some code that was used to compute the average of the yield in percent. But I'm having trouble computing the weighted average. I talked to some classmates and they said they're trying to use the formula:  sum(x*w)/sum(w) where w is weight.
  But I'm having trouble implementing this into my code</p>
  
  <pre><code>SELECT Nations.nationName, 
  AVG(dividend/price) AS Yield
  FROM Shares, Nations
  WHERE Shares.nationID=Nations.ID
  GROUP BY Nations.nationName;
  </code></pre>
  
  <p>In the end the weighted average should be computer but I just don't know how to implement that into the code. The material we're supposed to base this problem off of is no help.</p>