title: Order by multiple columns with
body: <p>I'm trying to sort a table by multiple columns, but I should shift the most important column.</p>
  <p>Given a sample like:</p>
  <pre><code>Name   Col1 Col2 Col3
  Paul      1    2    1
  John      1    1    1
  Greg   NULL    2    1
  Jane      2    2    1
  </code></pre>
  <p>I would like the data to be sorted like <code>John</code>, <code>Paul</code>, <code>Greg</code> and <code>Jane</code>.</p>
  <p>If I do <code>ORDER BY Col1, Col2, Col3</code>, <code>Greg</code> is the first result because of <code>NULL</code>.
  What I'm trying to do is to &quot;shift&quot; the columns, to discard all the NULL values</p>
  <p>Edited:</p>
  <p>The desired result is</p>
  <ul>
  <li>John</li>
  <li>Paul</li>
  <li>Greg</li>
  <li>Jane</li>
  </ul>
  <p>Greg ends up third because the query should remove the null value, working on a &quot;fixed&quot; version like</p>
  <pre><code>Name   Col1 Col2 Col3
  Paul      1    2    1
  John      1    1    1
  Greg      2    1    -  &lt;== Greg cols moved to the left by one step
  Jane      2    2    1
  </code></pre>
  <p>Edit2:</p>
  <p>I think that something like the <a href="https://www.mysqltutorial.org/mysql-coalesce/" rel="nofollow noreferrer">COALESCE</a> function should help.
  If I run:</p>
  <pre><code>SELECT Name, COALESCE(Col1, Col2, Col3, 0) FROM Table1
  </code></pre>
  <p>The result is:</p>
  <pre><code>Paul  1
  John  1
  Greg  2
  Jane  2
  </code></pre>