title: T-SQL - Return right-most non-zero column
body: <p>I have a strange scenario where I need to return the right-most non-zero column in a table structured as follows:</p>
  
  <pre><code>GL           Q1          Q2          Q3          Q4
  1            100         0           0           0
  2            100         900         250         0
  3            600         100         0           1000
  </code></pre>
  
  <p>I am expecting the output to be:</p>
  
  <pre><code>GL           Amount
  1            100
  2            250
  3            1000
  </code></pre>
  
  <p>Is there anyway to accomplish this as a set-based approach without having to resort to a CASE statement or similar solution?   Performance is going to be important here.</p>