建了一个视图,字段ID,parentID,LEAF
父节点parentID为空,子节点parentID是所属父节点的ID
如何过滤掉没有子节点的父数据行。

解决方案 »

  1.   

    LEAF字段是所有子节点都有同一个值,父节点都为空
      

  2.   

    select *
      from t_aa1 t
     where t.id not in
           (select a.parentid from t_aa1 a where a.parentid is not null)
       and t.leaf is null;
    貌似这个sql就可以满足你需求
      

  3.   


    好像理解错你意思了。你是要不查没有子节点的父行,其他都查询出来啊?
    select * from t_aa1  t where 
    t.id in (select a.parentid from t_aa1 a )
    or t.leaf is not null;
      

  4.   

    select *
      from t_aa1  
     start with parentid is null
    connect by prior id= parentid