title: Recursive query in db2
body: <p>I am having a problem with recursive query and I can not solve. 
  The problem is this: I want to get the tree of customer accounts of a business in the following table:</p>
  
  <pre><code> header table: accounts {id,code,account,dad_id}
  id is PK and dad_id is FK references id
      {1,1,'property',null}
      {2,2,'for result',null}
      {3,1,'actives',1}
      {4,2,'passives'1}
      {5,1,'not attributable active',3 }
  </code></pre>
  
  <p>my recursive sql and my problem for built the tree.</p>
  
  <pre><code>WITH TEMP(id,code,account,dad_id) AS(
   SELECT id,code,account,dad_id 
   FROM FINAL.ACCOUNT a
   WHERE a.dad_id IS NOT  NULL 
   UNION ALL
   SELECT a.id,a.code,a.account,t.dad_id
   FROM FINAL.ACCOUNT a, TEMP t
   WHERE a.dad_id=t.dad_id
  )
  select * from TEMP;
  </code></pre>
  
  <p>Expected result
   code </p>
  
  <pre><code>1.0 property
   1.1 Actives 
     1.1.1 Non atribbutable active 
   1.2 Passive 
  2.0 for result
  </code></pre>
  
  <p>from already thank you very much for reading, I'm open to all answers 
  thanks</p>