title: How to have a CASE WHEN query with multiple THEN in it?
body: <p>My code has been written as:</p>
  
  <pre><code>SELECT name, age,
    CASE WHEN abs(10 - mean(valueLeft)) &lt; abs(10 - mean(valueRight)) THEN stddev(valueLeftMagnitude) ELSE stddev(valueRightMagnitude) END as value1,
    CASE WHEN abs(10 - mean(valueLeft)) &lt; abs(10 - mean(valueRight)) THEN mean(valueLeftMagnitude) ELSE mean(valueRightMagnitude) END as value2,
    CASE WHEN abs(10 - mean(valueLeft)) &lt; abs(10 - mean(valueRight)) THEN median(valueLeftMagnitude) ELSE median(valueRightMagnitude) END as value3
  FROM table
  GROUP BY name, age
  </code></pre>
  
  <p>As the WHEN statement in all three CASE are same I want not to repeat them. Is there any way to do it?</p>
  
  <p>EXAMPLE : I want something like -</p>
  
  <pre><code>SELECT name, age,
    CASE WHEN abs(10 - mean(valueLeft)) &lt; abs(10 - mean(valueRight))
      THEN stddev(valueLeftMagnitude) ELSE stddev(valueRightMagnitude) END as value1,
      THEN mean(valueLeftMagnitude) ELSE mean(valueRightMagnitude) END as value2,
      THEN median(valueLeftMagnitude) ELSE median(valueRightMagnitude) END as value3
  FROM table
  GROUP BY name, age
  </code></pre>
  
  <p>Please help out.</p>