Neo4j Aggregate Query

Neo4j is a Graph database that supports multiple aggregate query operations, including Count, Sum, Average, Min, Max, Group by, etc. Below is a brief introduction to the table structure and sample data of Neo4j: Table structure example: Nodes contain labels and attributes, relationships contain types and attributes. Example nodes: Person (attributes: name, age), Movie (attributes: title, release_year) Example relationship: ACTED_ IN (attributes: roles), DIRECTED (attributes: awards) Example data: //Create nodes and relationships CREATE (:Person {name:'Tom Hanks', age:64})-[:ACTED_IN {roles:['Forrest Gump']}]->(:Movie {title:'Forrest Gump', release_year:1994}) CREATE (:Person {name:'Robert Zemeckis'})-[:DIRECTED {awards:3}]->(:Movie {title:'Forrest Gump', release_year:1994}) CREATE (:Person {name:'Gary Sinise', age:66})-[:ACTED_IN {roles:['Lt. Dan Taylor']}]->(:Movie {title:'Forrest Gump', release_year:1994}) CREATE (:Person {name:'Robin Wright', age:55})-[:ACTED_IN {roles:['Jenny Curran']}]->(:Movie {title:'Forrest Gump', release_year:1994}) CREATE (:Person {name:'James Cameron'})-[:DIRECTED {awards:4}]->(:Movie {title:'Titanic', release_year:1997}) The following are examples of various aggregated queries: 1. Count count query: //Count the number of all Person nodes MATCH (p:Person) RETURN COUNT(p) AS total 2. Sum query: //Count the total age of all Person nodes MATCH (p:Person) RETURN SUM(p.age) AS total_age 3. Average query: //Calculate the average age of all Person nodes MATCH (p:Person) RETURN AVG(p.age) AS avg_age 4. Min minimum value query: //Find the youngest Person node MATCH (p:Person) RETURN MIN(p.age) AS min_age 5. Max maximum query: //Find the oldest Person node MATCH (p:Person) RETURN MAX(p.age) AS max_age 6. Group by group query: //Group movies by year of release and count the number of movies per year MATCH (m:Movie) RETURN m.release_year AS year, COUNT(m) AS movie_count ORDER BY year The above examples demonstrate some common aggregation query operations of Neo4j. For detailed query syntax and more complex integration query operations, please refer to the official documentation of Neo4j.