title: How can I sum value of distinct columns
body: <p>I have two column(col1 and col 2) <code>col1</code> is VARCHAR datatype and <code>col2</code> is INT. I have many records with duplicate <code>col1</code> value. Now I need to sum(col2) where <code>col1</code> is distinct. How can i do this ?</p>
  
  <p>I tried like this before, but didn't work.</p>
  
  <pre><code>Select distinct 
      col1, sum(col2) as col2 
  from mytable 
  group by col1
  
  Select sum(col2) 
  from
      (Select distinct col1 from mytable)
  </code></pre>