title: Oracle Hierarchical query: how to include top-level parent
body: <p>I have a hierarchical query to track a reporting structure.  This almost works, except that it's not reporting the very top level node, probably because the top-level people "report" to themselves.</p>
  
  <p>The query is:</p>
  
  <pre><code>select
    level,
    empid, 
    parentid
  from usertable
  connect by nocycle prior parentid= empid
  start with empid = 50
  </code></pre>
  
  <p>This produces:</p>
  
  <pre><code>LEVEL  EMPID PARENTID               
  ------ ----- --------  
  1      50    258            
  2      258   9555
  3      9555  17839
  </code></pre>
  
  <p>I'm not getting a level 4, since it would look like:</p>
  
  <pre><code>4      17839 17839
  </code></pre>
  
  <p>Without changing data, is there a way to modify my query so that all 4 levels are returned?  The goal is to get the empids, so I can do a check for</p>
  
  <p><code>id in (hierarchical subquery)</code></p>
  
  <p>BTW, if I remove the nocycle from the query I get an error.</p>