title: How to get the sum of a column based on a distinct key (different column)
body: <p>I wanted to know how to get the distinct sum of products</p>
  
  <p>The table I have</p>
  
  <pre><code>Name Rating
   A     3
   A     3
   B     4
   C     3
   C     3
  </code></pre>
  
  <p>The final result I want is 
  <code>SUM(case when distinct table1.name then rating)/Count(case when distinct table1.name then rating)
  </code>
  final answer = (3+4+3)/3 = 10/3 = 3.33</p>
  
  <p>Thanks in advance </p>