I am facing an issue while using the CONNECT BY
clause in Oracle for finding hierarchical data. Let me give an example: A is my parent part which has child part B and B also has a child part C. When I am using the CONNECT BY
clause I am able to get all the three levels but I only want the top most level, i.e. A.
相关问题
- Can I skip certificate verification oracle utl_htt
- how to calculate sum time with data type char in o
- keeping one connection to DB or opening closing pe
- System.Data.OracleClient not working with 64 bit O
- How can I get rid of dynamic SQL
相关文章
- node连接远程oracle报错
- oracle 11g expdp导出作业调用失败,提示丢包。
- 执行一复杂的SQL语句效率高,还是执行多少简单的语句效率高
- Oracle equivalent of PostgreSQL INSERT…RETURNING *
- Difference between FOR UPDATE OF and FOR UPDATE
- Oracle USING clause best practice
- Is there a method in PL/SQL to convert/encode text
- PHP PDO installation on windows (xampp)
Oracle has a
LEVEL
pseudocolumn that you can use:To find a top-level (root) value from any level, precede the column name with the
CONNECT_BY_ROOT
operator:I am adding this solution for tables with one or multiple trees (hierarchical data).
Starting with one node (row) somewhere in the tree (hierarchical data), wanting to find the top node (root).
The query is taking advantage of the fact that the ONLY the top node (root) of a tree don't have a parent, which is a very common attribute of the top node (root) in any tree structure.