title: How do I get the average from a mysql column minus highest and lowest value
body: <p>I'm stumped. I want to get the average "clicks" from "posts" but throw away the highest value which typically is so high that it skews the threshold when I want to display all posts with clicks above the average. I also want to discard the lowest value for the same reason. My code is:</p>
  
  <pre><code>//get the sum of the clicks from all posts    
  
  $gettotalsum = mysql_query("SELECT sum(clicks) AS click_total FROM posts WHERE clicks &gt; '0' "); 
  
  $clicksum = @mysql_fetch_array($gettotalsum);
  
  
  //get the number of posts that have clicks                      
  $postcount = mysql_query("SELECT postid FROM posts WHERE isactive = 'y' AND clicks &gt; '0' "); 
  
  $clickcount = mysql_num_rows($postcount);   
  </code></pre>
  
  <p>I suspect that the two queries above are what I need to modify to filter highest and lowest click values - but how?</p>
  
  <p>and here's the rest of my code fwiw:        </p>
  
  <pre><code>//multiply to get the average, then round it off
  $average = $clicksum['clicks'] / $clickcount;
  $average = round($average); 
  
  //display posts that are equal to or above average
  
  $getposts = mysql_query("SELECT postid, posturl, posttitle, clicks FROM posts WHERE clicks &gt;= $average order by clicks DESC");
  
      while ($aboveaverageposts = @mysql_fetch_array($getposts)) {
  
      //code to format output goes here
  
      }
  </code></pre>
  
  <p>I do suspect all this code can be streamlined, but most important right now I'm looking to filter the highest and lowest values.</p>
  
  <p>Thanks in advance.</p>