0PricingLogin
Neo4j Graph Database Fundamentals · Lesson

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

All lessons in this course

  1. Filtering and Ordering Results
  2. Aggregation and Projections
  3. Updating and Deleting Graph Data
  4. Combining Queries with WITH and UNION
← Back to Neo4j Graph Database Fundamentals