我需要在查询期间聚合数据,然后按此数据排序。
根据密码文档:
如果要使用聚合对结果集进行排序,则聚合必须包含在 RETURN 中才能在 ORDER BY 中使用。
我有以下密码查询:
START profile=node(31) MATCH (profile)-[r:ROLE]->(story)
WHERE r.role="LEADER" and story.status="PRIVATE"
WITH story MATCH (story)<-[r?:RATED]-()
RETURN distinct story ,sum(r.rate) as rate ORDER BY rate DESCENDING
上面的查询工作正常,问题是我必须在我的结果集中包含sum(r.rate)。
当查询响应应该是故事列表/页面时,我正在通过存储库(我的存储库扩展 CypherDslRepository )使用Cypherdsl ...
我可以使用聚合函数排序而不将其包含在结果集中吗?
有什么解决方法吗?
谢谢。