title: Select top sold product from sales table
body: <p>I have a sales table with those rows:</p>
  
  <p><a href="https://i.stack.imgur.com/Sl90S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Sl90S.png" alt="Sales table"></a></p>
  
  <p>cd_produto is the product code and qtd_produto is the quantity of the product that has been sold(daaah)</p>
  
  <p>I want to get the top sold products. In this case it would be product #1 since it sums to 8 (1+7).
  The second would be #3 because it's 6.</p>
  
  <p>If i run </p>
  
  <pre><code>SELECT TOP 3 cd_produto, qtd_produto FROM itens_vendas ORDER BY qtd_produto DESC
  </code></pre>
  
  <p>I'll get them by top sales. But it would not sum the qtd for each individual product. It would consider 1 as the top sold but only because it's value is 7, and it will ignore the 1.</p>
  
  <p>How do i order them by the SUM of each product?</p>