title: Is it possible to make a recursive SQL query?
body: <p>I have a table similar to this:</p>
  
  <pre><code>CREATE TABLE example (
    id integer primary key,
    name char(200),
    parentid integer,
    value integer);
  </code></pre>
  
  <p>I can use the parentid field to arrange data into a tree structure.</p>
  
  <p>Now here's the bit I can't work out. Given a parentid, is it possible to write an SQL statement to add up all the value fields under that parentid and recurse down the branch of the tree ?</p>
  
  <p><strong>UPDATE:</strong> I'm using posgreSQL so the fancy MS-SQL features are not available to me. In any case, I'd like this to be treated as a generic SQL question.</p>
  
  <p>BTW, I'm very impressed to have 6 answers within 15 minutes of asking the question! Go stack overflow!</p>