title: Directed Graph/Hierarchy SQl
body: <p>We have below data from upstream:-</p>
  
  <pre><code>child. Parent
  2.      1
  3.      1
  14.     1
  1.      4
  5.      1
  6.      7
  8.      7
  13.     8
  12.     8
  8.      13
  9.      10
  10.     11
  </code></pre>
  
  <p>sometimes, child appears in parent and vice versa, there is no set order and relations can be cylic too.</p>
  
  <p>Expected output is</p>
  
  <pre><code>child.  group
  1.       1
  2.       1
  3.       1
  4.       1
  5.       1
  6.       1
  7.       1
  8.       1
  12.      1
  13.      1
  
  9.       10
  10.      10
  11.      10
  </code></pre>
  
  <p>can someone suggest the possible solutions, i have tried directed sql but cyclic relations are being excluded</p>