title: Getting average from 3 columns in SQL Server
body: <p>I have a table with 3 columns (<code>smallint</code>) in SQL Server 2005.</p>
  
  <pre><code>Table Ratings
  ratin1 smallint,
  ratin2 smallint
  ratin3 smallint
  </code></pre>
  
  <p>These columns can have values from <code>0</code> to <code>5</code>.</p>
  
  <p>How can I select the average value of these fields, but only compare fields where the value is greater then <code>0</code>.</p>
  
  <p>So if the column values are <code>1</code>, <code>3</code> ,<code>5</code> - the average has to be <code>3</code>.
  if the values are <code>0</code>, <code>3</code>, <code>5</code> - The average has to be <code>4</code>.</p>