我想找到最多朋友和最少朋友的用户。这是我的查询:
"start n=node:users({query}) match p=n-[?:Friend*]->x
with distinct n,count(distinct x) as cnt "
+ "start n=node:users({query}) match p=n-[?:Friend*]->x
with distinct n,count(distinct x) as cnt1, min(cnt) as minnumber "
+ "start n=node:users({query}) match p=n-[?:Friend*]->x
with distinct n,count(distinct x) as friendsNumber, max(cnt1) as
maxnumber, minnumber "
+ "where friendsNumber=minnumber or friendsNumber=maxnumber return n.name,
friendsNumber"
n 是用户,x 是他的朋友。但我使用了三个嵌套查询,我认为它的性能不好。还有其他方法吗?谢谢。