title: Average by distinct rows sql
body: <p>I have a table like this</p>
  
  <pre><code>Name          cost        profit
  Iphone         400         50
  Xperia          300         40
  Galaxy         420         55
  Xperia          330         50
  Iphone         600         70
  </code></pre>
  
  <p>I would like to have a table like this:</p>
  
  <pre><code>Name      avg(cost)   avg(profit)
  Iphone       500              60
  Galaxy       420              55
  Xperia        315              45
  </code></pre>
  
  <p>Thank you!</p>