title: PL/SQL getting average value in case statement
body: <p>THE TABLE:</p>
  
  <pre><code>+-----+----+----------+
  | QTR | MO | PCT_PERF |
  +-----+----+----------+
  |   1 | 1  |       89 | 
  |   1 | 2  |       73 |
  |   1 | 3  |       95 |
  +-----+----+----------+
  </code></pre>
  
  <h2>What is the proper syntax for this?</h2>
  
  <pre><code>CASE WHEN QTR=1 THEN ROUND(SUM(PCT_PERF WHERE MO IN (1,2,3))/3,2)
   WHEN QTR=2 THEN ROUND(SUM(PCT_PERF WHERE MO IN (4,5,6))/3,2) 
   WHEN QTR=3 THEN ROUND(SUM(PCT_PERF WHERE MO IN (7,8,9))/3,2)
   ELSE ROUND(SUM(PCT_PERF WHERE MO IN (10,11,12))/3,2) END QTR_PCT
  </code></pre>
  
  <p>So that WHEN QTR is 1, QTR_PCT should be 86.
  <em>(89+73+95)/3 = 85.67</em></p>