title: SQL - sorting table with parent child relation
body: <p>We have a table with a parent-child relation and would like to get it sorted. The sorting criteria is so that when iterating though the result the row matching a parent ID should already be there :</p>
  
  <pre><code>ID   PARENT_ID 
  EF01 EF02         // This is wrong as the row EF02 is after and will fail.
  EF02    
  BB   AA           // here BB &lt; AA
  AA   EF01 
  </code></pre>
  
  <p>The problem is that both key are string, therefore sorting by ID or PARENT_ID is not going to fix the problem.</p>