title: Average with condition
body: <p>I am trying to figure out how to calculate the exact average of a variable.
  Currently I have this query: (simplified):</p>
  
  <pre><code>select ID , Group_ID, Chargeability,Job_No_, Group_Charg FROM Data1
  
  
  ID      Group ID        Chargeability       Job No_     Group Chargeability
  1             a             90                c1                 88.11
  1             a             90                c2                 88.11
  1             a             90                c3                 88.11
  1             a             90                c4                 88.11
  2             a             85.6              c8                 88.11
  2             a             85.6              c17                88.11
  2             a             85.6              c6                 88.11
  </code></pre>
  
  <p>The average calculated is not the actual one. The Chargability is fixed for each ID so that the average should not take into consideration the number of rows per ID because it is just a replacement of the value as we have lotz of job_No per each ID.</p>
  
  <p>I.e I would like to have <code>Group_chargeability</code> = (90+85.6)/2 instead of (90*4)+(85.6*3)/7 as currently is doing.</p>
  
  <p>The query is made up of several sub-queries, some of them also calling function. This is why I cannot use group by to try to solve the issue I have.</p>