Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は最も多くの子供を持つ親を見つけようとしています。これはそれほど難しいことではないと思いますが、苦労しています。
postgresql と Ltree を使用しています。
ありがとうございました
これは、他の場合と同じロジックです。親を提供する関数を見つけて、それによってグループ化します。これはうまくいくはずです:
SELECT subpath(path,0,1), count(*) FROM test GROUP BY subpath(path,0,1) ORDER BY count(*) DESC limit 1;
http://sqlfiddle.com/#!12/8fb17/5