title: SQL: Show average and min/max within standard deviations
body: <p>I have the following SQL table - </p>
  
  <pre><code>Date       StoreNo       Sales
  23/4            34     4323.00
  23/4            23      564.00
  24/4            34     2345.00
  etc
  </code></pre>
  
  <p>I am running a query that returns average sales, max sales and min sales for a certain period -</p>
  
  <pre><code>select avg(Sales), max(sales), min(sales)
  from tbl_sales
  where date between etc
  </code></pre>
  
  <p>But there are some values coming through in the min and max that are really extreme - perhaps because the data entry was bad, perhaps because some anomoly had occurred on that date and store. </p>
  
  <p>What I'd like is a query that returns average, max and min, but somehow excludes the extreme values. I am open to how this is done, but perhaps it would use standard deviations in some way (for example, only using data within x std devs of the true average).</p>
  
  <p>Many thanks</p>