RETURN

MATCH (n:Person)
RETURN n.name AS person, n.age AS years
ORDER BY n.age DESC
LIMIT 10

Project 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.age

Ordering#

MATCH (n:Person) RETURN n.name ORDER BY n.age DESC

Pagination#

MATCH (n:Person) RETURN n.name ORDER BY n.age SKIP 5 LIMIT 10

Distinct#

MATCH (n:Person) RETURN DISTINCT n._labels

Column 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 orgName

This 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#

Try it
Open ↗
Loading engine…