我正在使用PostgreSQL,并且有一个带有类型的路径列的表ltree.
我试图解决的问题是:给定整个树结构,除了根之外,哪个父项具有最多的子项.
示例数据如下所示:
path column = ; has a depth of 0 and has 11 children its id is 1824 # dont want this one because its the root
path column = ; has a depth of 0 and has 1 children its id is 1823
path column = 1823; has a depth of 1 and has 1 children its id is 1825
path column = 1823.1825; has a depth of 2 and has 1 children its id …Run Code Online (Sandbox Code Playgroud)