title: Order by cases- sorting by dynamic column
body: <p>In my procedure I have:</p>
  
  <pre><code>SELECT
      Col1,
      Col2,
      (Col1+ Col2) AS Col3
  FROM Table1
  ORDER BY 
      CASE WHEN @SortColumn='Col1' THEN Col1 END ASC,
      CASE WHEN @SortColumn='Col3' THEN Col3 END ASC -- PROBLEM HERE
  </code></pre>
  
  <p>The problem is that I can't sort by column which doesn't exist in <code>Table1</code>. I tried with <code>CASE WHEN @SortColumn='Col3' THEN 'Col3' END ASC</code> but it doesn't work either.</p>