title: MySQL and average of multiple columns
body: <p>I need to return average for each of 12 columns I have in a table in DB. MySQL allows one to get average for one column only. The following query (for one column) works:</p>
  
  <pre><code>SELECT station_id, AVG(jan) AS avg_jan
  FROM `climate_data`
  
  WHERE element_name = "Temp_mean_mly" AND jan &lt;&gt; -999999  
  GROUP BY station_id 
  </code></pre>
  
  <p>and the following (for multiple columns) does not (I get syntax error):</p>
  
  <pre><code>SELECT station_id, AVG(jan) AS avg_jan, AVG(feb) AS avg_feb, ... , 
  AVG(dec) AS avg_dec 
  FROM `climate_data`
  
  WHERE element_name = "Temp_mean_mly" 
  AND jan &lt;&gt; -999999 
  AND feb &lt;&gt; -999999
  AND ... 
  AND dec &lt;&gt; -999999 
  GROUP BY station_id 
  </code></pre>
  
  <p>Do I have to use 12 sub-queries to achieve the result I need?</p>