title: sum of recursive tree using Postgres?
body: <p>I have a tree structure that looks like this:</p>
  <pre><code>                                     root
                         A                               B
                A1           A2                     B1        B2
            A1.1  A1.2      A2.1                   B1.1
  </code></pre>
  <p>the table looks something like this:</p>
  <pre><code>id | name |value | parent_id
  1    root   null    null
  2    A      null    1
  3    B      null    1    
  4    A1     null    2
  5    A1.1   2       4
  6    A1.2   3       4
  .........................
  </code></pre>
  <p>the non leaf nodes must contain the sum of their children leaf nodes.</p>
  <p>how can i achieve this with a fast Postgres query</p>