RETURN
MATCH (n:Person)
RETURN n.name AS person, n.age AS years
ORDER BY n.age DESC
LIMIT 10Project query results with aliases, ordering, pagination, and deduplication.
Syntax#
RETURN expression [AS alias], ...
[ORDER BY expression [ASC|DESC]]
[SKIP n]
[LIMIT n]Examples#
Basic projection#
MATCH (n:Person) RETURN n.name, n.ageOrdering#
MATCH (n:Person) RETURN n.name ORDER BY n.age DESCPagination#
MATCH (n:Person) RETURN n.name ORDER BY n.age SKIP 5 LIMIT 10Distinct#
MATCH (n:Person) RETURN DISTINCT n._labelsColumn names and aliases#
Each item in the projection becomes one column. The column name comes from the expression itself: n.name becomes the column name. When two projections produce the same column name, the second overwrites the first — there is one column called name, not two.
-- Two variables, both projecting `.name` → one column "name"
MATCH (a:Person) MATCH (b:Org) RETURN a.name, b.name
-- Distinct columns require AS aliases
MATCH (a:Person) MATCH (b:Org) RETURN a.name AS personName, b.name AS orgNameThis is standard Cypher behavior. Traversal queries (MATCH (a)-[:REL]->(b) RETURN a.name, b.name) face the same rule — alias whenever names would collide.
See Also#
- Aggregations — COUNT, SUM, AVG, COLLECT
- EXPLAIN — see the query plan
Try it
Open ↗⌘↵ to run
Loading engine…