title: How to divide by the result of another query
body: <p>This is a separate question based on a previous post:</p>
  
  <p>[Link] <a href="https://stackoverflow.com/questions/21381754/how-to-calculate-grand-totals-when-using-over-partition-by-using-oracle-sq">How to calculate Grand Totals when using OVER (partition by ...) using Oracle SQL</a></p>
  
  <p>I am using the following Oracle SQL query:</p>
  
  <pre><code>SELECT JOB_GROUP,
     SUM(PEOPLE) AS CURRENT_PEOPLE
     SUM(PEOPLE) / '100' AS RATIO
  FROM MY_VIEW
  WHERE MONTH = '01-DEC-2013'
  GROUP BY ROLLUP (OB_GROUP)
  ORDER BY RATIO DESC;
  </code></pre>
  
  <p>This query gives me an output like this..</p>
  
  <pre><code>JOB_GROUP    CURRENT_PEOPLE    RATIO
  WORKER1     100                1.0
  WORKER2     30                 .3
  WORKER3     40                 .4
  WORKER4     25                 .25
  WORKER5     30                 .30
  (NULL)      225                2.25
  </code></pre>
  
  <p>I need to be able to divide the sum of all of the ratios into the sum of the ratios where job_group = 'WORKER1', WORKER2, WORKER4. For Example, we can have 5 different job_groups, but I only need the sum of the ratio for 1, 2 and 4.  I suspect this is some type of subquery, but have not been able to get the right result yet.</p>
  
  <p>The equation would look like sum(ratios) / sum(ratio) where worker, 1,2,4.  2.25 / (1.0 + .3 + .25) = .80</p>
  
  <p>Thanks for any help you can provide,</p>