title: How to calculate percentage by count of column values group by week?
body: <p>I have a table view like this:</p>
  <pre><code>week    ColB    ColF
  ---------------------
  45      1234    PART
  45      8215    TEMP
  45      2834    PART
  45      4152    PART
  45      5775    TEMP
  45      6527    PART
  45      1162    TEMP
  45      9154    
  45      2162    
  46      4232    PART
  46      3215    PART
  46      5834    PART
  46      6152    PART
  46      7775    TEMP
  46      8527    PART
  46      9162    TEMP
  46      2354    
  46      2562    
  46      9762    
  ...
  ...
  ...
  </code></pre>
  <p>Now for each week I need to do below things:</p>
  <ul>
  <li>For each week, how many total <code>PART</code> and <code>TEMP</code> are there. Let's call this <code>total</code>. In <code>ColF</code> I can have other values as well apart from <code>PART</code> and <code>TEMP</code> like empty string or any other values. I just need to count <code>PART</code> and <code>TEMP</code> only.</li>
  <li>For each week, how many <code>TEMP</code> are there. Let's call this <code>temp</code>.</li>
  <li>For each week, divide <code>temp</code>/<code>total</code> and get the percentage.</li>
  </ul>
  <p>So output should be like this. Basically group by on week column.</p>
  <pre><code>week    ratio
  ---------------------
  45      5.5%
  46      4.3%
  47      2.3%
  48      1.7%
  </code></pre>
  <p>I was trying like this but somehow not understanding fully on how to achieve above result? My below query is wrong -</p>
  <pre><code>select week, (SELECT week, count(*) FROM process WHERE ColF = 'TEMP' group by week) / count(*)
  from process where ColF IN ('PART', 'TEMP')
  group by week
  order by week
  </code></pre>
  <p>Is this possible to do by any chance?</p>