如何在Cypher中对BY进行排序以将“空”结果以降序排列回去?通过documentation,空结果排在第一位,降序排列。
MATCH (n:Title)
WHERE n.primaryTitle STARTS WITH "D"
RETURN n.primaryTitle, n.startYear, n.ratings, n.numberOfVotes
ORDER BY n.numberOfVotes DESC
LIMIT 7
答案 0 :(得分:0)
您可以在coalesce
中将ORDER BY
的null设为零。
MATCH (n:Title)
WHERE n.primaryTitle STARTS WITH "D"
RETURN n.primaryTitle, n.startYear, n.ratings, n.numberOfVotes
ORDER BY coalesce(n.numberOfVotes,0) DESC
LIMIT 7
或者您可以简单地合并返回的属性。
MATCH (n:Title)
WHERE n.primaryTitle STARTS WITH "D"
RETURN n.primaryTitle, n.startYear, n.ratings, coalesce(n.numberOfVotes,0)
ORDER BY n.numberOfVotes DESC
LIMIT 7