title: ORA-00904: invalid identifier in subquery
body: <p>Why the query below doesn't work in oracle?</p>
  
  <pre><code>select * from ENTITY_OWNERSHIP EO
  where 
  (select count (*) 
      from (
        select USER_ID 
        from ENTITY_OWNERSHIP 
        where ENTITY_OWNERSHIP.ENTITY_ID = EO.ENTITY_ID
      )
  ) &gt; 0
  </code></pre>
  
  <p>It produces "ORA-00904: "EO"."ENTITY_ID": invalid identifier". However when I replace EO.ENTITY_ID with exact value, for example, 10181 then it works.</p>
  
  <p>UPDATE:
  The full query looks like:</p>
  
  <pre><code>select * from ENTITY_OWNERSHIP EO
  where 
  (select count (*) 
      from (
        select USER_ID 
        from ENTITY_OWNERSHIP 
        where ENTITY_OWNERSHIP.ENTITY_ID = EO.ENTITY_ID
  
        intersect
  
        select distinct group_id
        from USERS.GROUPS 
        start with GROUP_ID in (select GROUP_ID from USERS.LK_GROUPS where USER_ID=10001)
        connect by prior PARENTGROUP_ID=GROUP_ID 
      )
  ) &gt; 0
  </code></pre>