How to query tree table structure which has no subnodes
<p>I have data organized as a tree in Oracle 11g. </p>

<pre><code>CREATE TABLE FOLDER
(
  NAME VARCHAR2(20),
  ID NUMBER(10, 0),
  PARENT_ID NUMBER(10, 0)
}
</code></pre>

<p>(I think this structure is obvious and I should explain it).</p>

<p>Trying to query only data that has no subfolders. Using this query (not sure its correct):</p>

<pre><code>SELECT * FROM folder f WHERE NOT EXISTS ( 
   SELECT *
    FROM folder cf
    WHERE f.id= cf.parent)
</code></pre>

<p>Is there possibility to use more optimal query for this purpose, for example using COUNT ?</p>