title: ORDER BY with Case-Statement DESC
body: <ul>
  <li>How to <code>ORDER BY</code> with a <code>CASE</code>-Statement 
  <ul>
  <li>first group:  null values in date-column <code>Col1</code> sorted by date-column <code>Col2 DESC</code></li>
  <li>second group: not-null values in date-column-<code>Col1</code> sorted by <code>Col1 DESC</code></li>
  </ul></li>
  </ul>
  
  <p>I've tried following:</p>
  
  <pre><code>SELECT columns FROM tables WHERE condition
  ORDER BY 
      case when Table1.Col1 IS NULL     then 0 end, Table2.Col2 DESC,
      case when Table1.Col1 IS NOT NULL then 1 end, Table1.Col1 DESC
  </code></pre>
  
  <p>But the sort order is wrong, the NOT NULL values are first(sorted by Col2 instead of Col1). I think i've missed a detail.</p>