neo4j
Sort nodes in descending order Cypher query neo4j
To order rows in descending order using Cypher query in neo4j graph database, ORDER BY clause can be used. You can understand it using the below example.
MATCH (n)
RETURN n.firstname, n.lastname, n.age
ORDER BY n.age DESC
In the above Cypher query, we are getting firstname, lastname, age property from nodes and sorting them in descending order. We are using the ORDER BY node.property to sort the records and using the DESC keyword to sort in descending order.
MATCH (n:Product)
RETURN n.product_name, n.order_id
ORDER BY n.order_id DESC
LIMIT 5
The above Cypher query will order nodes that have Product label in descending order and return the first 5 nodes from that.
Was this helpful?
Similar Posts
- Sort nodes by id ascending and descending order neo4j Cypher query
- Get all nodes cypher query neo4j
- Get all nodes with same label using label name Cypher query neo4j
- Get all related nodes of a node using Cypher query neo4j
- Get nodes using multiple ids Cypher query neo4j
- Create one or multiple nodes Cypher query neo4j
- Delete nodes using Cypher query neo4j