小编Dav*_*inj的帖子

Postgresql ltree查询找到大多数孩子的父母; 排除根

我正在使用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)

sql postgresql tree ltree

1
推荐指数
1
解决办法
2239
查看次数

标签 统计

ltree ×1

postgresql ×1

sql ×1

tree ×1