title: Return the AVG of the Top 5 Values in Query Results
body: <p><strong>Question:</strong> How would I return the AVG of the Top 5 values in the Payment Ranking query below.</p>
  
  <p><strong>Database</strong>: Oracle 11g</p>
  
  <p><strong>Current Query</strong></p>
  
  <pre><code>select distinct pye.payeeid, pay.value,
  dense_rank() over (partition by bu.name order by pay.value DESC) as "Payment Ranking"
  
  from cs_period per, cs_payee pye, cs_payment pay, cs_businessunit bu
  
  where per.name = 'August 2014'
  and pye.payeeseq = pay.payeeseq
  and pay.businessunitmap = bu.mask
  and pye.effectiveenddate = to_date('01/01/2200','dd/mm/yyyy')
  and pye.removedate = to_date('01/01/2200','dd/mm/yyyy')
  and per.periodseq = pay.periodseq
  order by pay.value DESC
  </code></pre>
  
  <p><strong>Results</strong></p>
  
  <p><img src="https://i.stack.imgur.com/3CORG.png" alt="enter image description here"></p>