title: SQL Exclusion in the select query
body: <p>I have a SQL Server query which is processing several thousands of rows. However the script runs fine, but I need to apply to just one of the select statements a criteria but not have it affect the rest of the results. </p>
  
  <pre><code>Select
      Count ([key]) as KEYCOUNT, 
      Round (AVG ([AGE]),2) as AGE, 
      Round (AVG ([LENGTH]),2) as Length_X,
      Round (AVG ([Duration]),2) as DUR_Y,
  from 
      [dbo].[XYZ]
  where 
      [FLAG] = 1  and STAT = 3 
  </code></pre>
  
  <p>The select I need to affect is <code>Round (AVG ([LENGTH]),2) as Length_X</code>, which I need to calculate as the average of only those lengths which are greater than 0, basically excluding all 0 (zeros)</p>
  
  <p>Help much appreciated</p>
  
  <p>Cheers</p>