Aggregation and Projections
Discover how to use aggregation functions (e.g., COUNT, SUM) and project data into custom formats for analysis.
Analyze Your Graph Data
Welcome to Aggregation and Projections! In graph databases, you often need to do more than just find data; you need to summarize it or shape it for analysis.
Aggregation means calculating a single result from multiple items, like counting all nodes or finding the average age. Projection is about selecting and formatting the data you want to see in your results.
Selecting Data with RETURN
The RETURN clause is how you specify exactly what data you want to see from your query. You can return nodes, relationships, or their specific properties. Let's add some example data first, then try a basic projection.
CREATE (p1:Person {name: 'Alice', age: 30})
CREATE (p2:Person {name: 'Bob', age: 25})
CREATE (p3:Person {name: 'Charlie', age: 30})
CREATE (m1:Movie {title: 'Inception', releaseYear: 2010})
CREATE (m2:Movie {title: 'Dunkirk', releaseYear: 2017})
CREATE (m3:Movie {title: 'Interstellar', releaseYear: 2014})
MATCH (p:Person)
RETURN p.name, p.ageAll lessons in this course
- Filtering and Ordering Results
- Aggregation and Projections
- Updating and Deleting Graph Data
- Combining Queries with WITH and UNION