title: Postgres: get average for all values of a column for each distinct from another column
body: <p>I have a table that looks like:</p>
  
  <pre><code>sku | qty
  ----|----
  sku1|  1
  sku1|  3
  sku1|  1
  sku1|  3
  sku2|  1
  </code></pre>
  
  <p>And I'm trying to write a query that will return the average of <code>qty</code> for each distinct <code>sku</code>.
  So for the data above, the output from the query would look like:</p>
  
  <pre><code>sku | qty
  ----|----
  sku1| 2
  sku2| 1
  </code></pre>
  
  <p>So, the averages for <code>sku1</code> came from <code>1 3 1 3</code> and the average of <code>sku2</code> is just <code>1</code></p>
  
  <p>I know it's going to involve some kind of subquery, but I just can't seem to figure it out.</p>
  
  <pre><code>SELECT sku, AVG(qty)
  FROM (SELECT DISTINCT sku FROM table)
  </code></pre>
  
  <p>How do I query for the average qty for each sku?</p>