title: How can I group children and parents in a single query?
body: <p>I have a table that represents a simple parent->child hierarchy, something like:</p>
  
  <pre><code>             Table "public.transactions"
     Column  | Type          |  Modifiers
  -----------+---------------+-----------------------------------------------------------
   id        | integer       | not null default nextval('transactions_id_seq'::regclass)
   parent_id | integer       | not null default 0
   amount    | numeric(15,4) | not null default 0.0000
  </code></pre>
  
  <p>I'd like to display the table with child transactions (those with a parent_id > 0) grouped below their respective parents. e.g., </p>
  
  <pre><code>parent
     child
     child
  parent
     child
  parent
  parent
  </code></pre>
  
  <p><em>(note: nested spaces are only here to visually represent hierarchy, they're not needed for the query results)</em></p>
  
  <p>Can I do this in a single query? I'm running Postgresql 9.3 in case it matters.</p>