Ordering results
You can order the results of a query using the ORDER BY clause.
This query finds all the people born in 1980 and orders them by their birth date:
MATCH (p:Person)
WHERE p.born.year = 1980
RETURN p.born AS birthDate
ORDER BY p.bornYou can split dates into their components using the year, month, and day properties.
Ordering results
You can order by one or more columns, and specify the order as ascending (ASC) or descending (DESC).
MATCH (p:Person)
WHERE p.born.year = 1980
RETURN p.name AS name, p.born AS birthDate
ORDER BY p.born DESC, p.name ASCLimiting results
The number of results returned by a query can be limited using the LIMIT clause.
This query finds the first 5 movies released in the year 2000:
MATCH (m:Movie)
WHERE m.year = 2000
ORDER BY m.released
RETURN m.title, m.released
LIMIT 5Challenges
Complete the queries to find the following data:
- 
Steven Spielberg movies, ordered by the year they were released. cypherMATCH (p:Person)-[:DIRECTED]->(m:??????) WHERE p.???? = "Steven Spielberg" ????? ?? m.released RETURN m.title, m.released
- 
Return the top 10 most recently released movies cypherMATCH (m:Movie) ????? ?? m.released ???? RETURN m.title, m.released ????? 10
Click to reveal the answers
- 
Return Steven Spielberg movies, ordered by the year they were released. cypherMATCH (p:Person)-[:DIRECTED]->(m:Movie) WHERE p.name = "Steven Spielberg" ORDER BY m.released RETURN m.title, m.released
- 
Return the top 10 most recently released movies cypherMATCH (m:Movie) ORDER BY m.released DESC RETURN m.title, m.released LIMIT 10
Next
Summary
In this lesson, you learned how to order and limit the returned results.