title: The average duration of first 80% records
body: <p>For example I have the following list of calls:</p>
  
  <ul>
  <li>Call#1 - duration 30 min</li>
  <li>Call#2 - duration 43 min</li>
  <li>Call#3 - duration 26 min</li>
  <li>Call#4 - duration 35 min</li>
  <li>Call#5 - duration 39 min</li>
  </ul>
  
  <p>1) I need the SQL query retrieving <strong>the average duration</strong> of <strong>first 80% of calls</strong>. </p>
  
  <p>Calls that fall into first 80% (according to call duration) are calls #3,#1,#4,#5. For these calls the average duration should be calculated ((26+30+35+39)/4=32,5). Calls above 80% (here call #2) should be ignored.</p>
  
  <p>2) Also I need the vice versa query - <strong>what percentage of first calls will have the average call duration of 30 mins</strong>?</p>
  
  <p>3) Hot to fetch the <strong>duration of 80%-th record</strong> (ordered according to call duration). E.g. if there's 500 records, what's the duration of 400th record?</p>
  
  <p>How this SQL queries should look like (Oracle)?</p>