title: Find first non-null values for multiple columns
body: <p>I'm attempting to get the first non-null value in a set of many columns. I'm aware that I could accomplish this using a sub-query per column. In the name of performance, which really does count in this scenario, I'd like to do this in a single pass. </p>
  
  <p>Take the following example data:</p>
  
  <pre><code>col1     col2     col3     sortCol
  ====================================
  NULL     4        8        1
  1        NULL     0        2
  5        7        NULL     3
  </code></pre>
  
  <p>My dream query would find the first non-null value in each of the data columns, sorted on the <code>sortCol</code>.</p>
  
  <p>For example, when selecting the magical aggregate of the first three columns, sorted by the <code>sortCol</code> descending.</p>
  
  <pre><code>col1     col2     col3
  ========================
  5        7         0
  </code></pre>
  
  <p>Or when sorting ascending:</p>
  
  <pre><code>col1     col2     col3
  ========================
  1        4         8
  </code></pre>
  
  <p>Does anyone know a solution?</p>