Skip to main content

RETURN

The RETURN clause defines which properties and values the result-set will contain.

Basic Usage

The basic structure is a comma-separated list of alias.property expressions:

RETURN person.name, person.age

For convenience, you can specify just the alias to return all properties of an entity:

RETURN movie.title, actor

Removing Duplicates

Use the DISTINCT keyword to remove duplicate values from the result-set:

RETURN DISTINCT friend_of_friend.name

For example, if you have two friends (Joe and Miesha) who both know Dominick, DISTINCT ensures that Dominick appears only once in the final result set.

Aggregations

The RETURN clause can also aggregate data, similar to SQL's GROUP BY functionality.

When an aggregation function is used in the RETURN list, all non-aggregated values become implicit grouping keys:

RETURN movie.title, MAX(actor.age), MIN(actor.age)

This query groups data by movie title and, for each movie, returns the youngest and oldest actor ages.

Supported Aggregation Functions

FunctionDescription
avgCalculate average of numeric values
collectCollect values into a list
countCount number of values
maxFind maximum value
minFind minimum value
percentileContCalculate continuous percentile
percentileDiscCalculate discrete percentile
stDevCalculate standard deviation
sumCalculate sum of numeric values

For detailed information on aggregation functions, see the Functions documentation.