title: How to make SQL query to get parent child data in group
body: <p>I have one customer table, and have parent and sub customer in same table with "ParentId" field relation. Table as below.</p>
  
  <pre><code>CustId      CustName    ParentId
  ----------------------------------
  1           Cust1         0 
  2           Cust2         0
  3           Sub2Cust1     1
  4           Cust3         0
  5           Sub1Cust1     1
  6           Sub1Cust2     2
  7           Sub2Cust2     2
  8           Sub4Cust1     1
  9           Sub1Cust3     4
  10          Sub3Cust1     1
  </code></pre>
  
  <p>What I want is from MS SQL Query so it keep parent and child record together, Like output as below:</p>
  
  <pre><code>CustId      CustName    ParentId
  ----------------------------------
  1           Cust1          0 
  5           Sub1Cust1      1
  3           Sub2Cust1      1
  10          Sub3Cust1      1
  8           Sub4Cust1      1
  2           Cust2          0
  6           Sub1Cust2      2
  7           Sub2Cust2      2
  4           Cust3          0
  9           Sub1Cust3      4
  </code></pre>
  
  <p>Can anybody please give me a hint how to do it with single query?</p>
  
  <p>Thanks in advance</p>