TigerGraph aggregation query

TigerGraph is a high-performance Graph database that supports multiple aggregate query operations. Here are some aggregation query types and examples supported by TigerGraph: 1. Count: Counts the number of vertices or edges that meet specific conditions. Example: Calculate the number of all vertices in the graph. CREATE QUERY countVertices() FOR GRAPH MyGraph { SumAccum<int> @count; start = {Any}; start = select s from start:s accumulate s.@count += 1; print start.@count; } 2. Sum: Calculate the sum of the specified attribute. Example: Calculate the sum of the ages of all vertices in the graph. CREATE QUERY calculateAgeSum() FOR GRAPH MyGraph { SumAccum<int> @ageSum; start = {Person.*}; start = select s from start:s accumulate s.@ageSum += s.age; print start.@ageSum; } 3. Average: Calculate the average value of the specified attribute. Example: Calculate the average age of all vertices in the graph. CREATE QUERY calculateAverageAge() FOR GRAPH MyGraph { SumAccum<int> @ageSum; SumAccum<int> @count; start = {Person.*}; start = select s from start:s accumulate s.@ageSum += s.age, s.@count += 1; print start.@ageSum / start.@count; } 4. Max and Min: Calculate the maximum and minimum values of the specified attribute. Example: Calculate the maximum and minimum ages of all vertices in the graph. CREATE QUERY findMinMaxAge() FOR GRAPH MyGraph { MinAccum<int> @minAge; MaxAccum<int> @maxAge; start = {Person.*}; start = select s from start:s accumulate s.@minAge += s.age, s.@maxAge += s.age; print start.@minAge, start.@maxAge; } 5. Group by: Group according to specified attributes, and then perform aggregation operations on each group. Example: Calculate the number of people in each group grouped by gender. CREATE QUERY groupByGender() FOR GRAPH MyGraph { GroupAccum<int> @countByGender; start = {Person.*}; start = select s from start:s accumulate s.@countByGender += 1 group by s.gender; print start.@countByGender; } It should be noted that the table structure and sample data in the example here are not provided. You can make corresponding adjustments and implementations based on your own data model and requirements.