title: Recursion Query to get Children and its grandchildren
body: <p>I have one mapping table:</p>
  
  <pre><code>Code     Parent_code   Position
  --------------------------------
  H1       Null          Root
  H11      H1            Parent
  H111     H11           Parent
  H1111    H111          Leaf
  H1112    H111          Leaf 
  </code></pre>
  
  <p>One more table which stores amount for leaf level code</p>
  
  <pre><code>Code   Amount
  -------------
  H1111  100
  H1112  200
  </code></pre>
  
  <p>i.e amount is stored at only leaf position </p>
  
  <p>I want to write the query through which the data at leaf level will get rolled up to its parents and ultimately to its root.</p>
  
  <p>Output will look like below </p>
  
  <pre><code>Code   Amount
  -------------
  H1     300
  H11    300
  H111   300
  H1111  100
  H1112  200
  </code></pre>
  
  <p>Also if I select H1 that is root then output should be its children and its grandchildren.
  Same if I select H11 i should get the output as H111 And children of H111</p>