title: Redshift - Find % as compared to total value
body: <p>I have a table with count by product. I am trying to add a new column that would find % as compared to sum of all rows in that column.</p>
  
  <pre><code>prod_name,count
  prod_a,100
  prod_b,50
  prod_c,150
  </code></pre>
  
  <p>For example, I want to find % of prod_a as compared to the total count and so on.</p>
  
  <p>Expected output:</p>
  
  <pre><code>prod_name,count,%
  prod_a,100,0.33
  prod_b,50,0.167
  prod_c,150,0.5
  </code></pre>
  
  <p>Edit on SQL:</p>
  
  <pre><code>select count(*),ratio_to_report(prod_name)
  over (partition by count(*)) 
  from sales
  group by prod_name;
  </code></pre>