From 25829f56c086b3d7c89f25a6d8e52bd564670acb Mon Sep 17 00:00:00 2001 From: Abby <78209557+abby-cyber@users.noreply.github.com> Date: Tue, 22 Nov 2022 15:20:49 +0800 Subject: [PATCH 1/3] implicit-group-by --- .../8.clauses-and-options/group-by.md | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md index 12b0c9034d9..718da3b3f51 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md @@ -59,8 +59,6 @@ nebula> GO FROM "player100" OVER follow BIDIRECT \ +---------------------+------------+ ``` -## Group and calculate with functions - The following statement finds all the vertices connected directly to vertex `"player100"`, groups the result set by source vertices, and returns the sum of degree values. ```ngql @@ -76,3 +74,27 @@ nebula> GO FROM "player100" OVER follow \ ``` For more information about the `sum()` function, see [Built-in math functions](../6.functions-and-expressions/1.math.md). + + +## Implicit GROUP BY + +The usage of `GROUP BY` in the above nGQL statements that explicitly write `GROUP BY` and acts as grouping fields is called explicit `GROUP BY`, while in openCypher, the `GROUP BY` is implicit, i.e., `GROUP BY` groups fields without explicitly writing `GROUP BY`. The explicit `GROUP BY` in nGQL is the same as the implicit `GROUP BY` in openCypher, and nGQL also supports the implicit `GROUP BY`. For the implicit usage of `GROUP BY`, see [Implicit Group By](https://neo4j.com/docs/cypher-manual/current/functions/aggregating/#grouping-keys). + + +For example, to look up the players over 34 years old with the same length of service, you can use the following statement: + +```ngql +nebula> LOOKUP ON player WHERE player.age > 34 YIELD id(vertex) AS v | \ + GO FROM $-.v OVER serve YIELD serve.start_year AS start_year, serve.end_year AS end_year | \ + YIELD $-.start_year, $-.end_year, count(*) AS count | \ + ORDER BY $-.count DESC | LIMIT 5; ++---------------+-------------+-------+ +| $-.start_year | $-.end_year | count | ++---------------+-------------+-------+ +| 2018 | 2019 | 3 | +| 1998 | 2004 | 2 | +| 2012 | 2013 | 2 | +| 2007 | 2012 | 2 | +| 2010 | 2011 | 2 | ++---------------+-------------+-------+ +``` \ No newline at end of file From 02f7e7cf32d67d30274cbb9ec7505a79d174b0c5 Mon Sep 17 00:00:00 2001 From: Abby <78209557+abby-cyber@users.noreply.github.com> Date: Tue, 22 Nov 2022 16:18:10 +0800 Subject: [PATCH 2/3] Update group-by.md --- docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md index 718da3b3f51..c0aa2890694 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md @@ -78,7 +78,7 @@ For more information about the `sum()` function, see [Built-in math functions](. ## Implicit GROUP BY -The usage of `GROUP BY` in the above nGQL statements that explicitly write `GROUP BY` and acts as grouping fields is called explicit `GROUP BY`, while in openCypher, the `GROUP BY` is implicit, i.e., `GROUP BY` groups fields without explicitly writing `GROUP BY`. The explicit `GROUP BY` in nGQL is the same as the implicit `GROUP BY` in openCypher, and nGQL also supports the implicit `GROUP BY`. For the implicit usage of `GROUP BY`, see [Implicit Group By](https://neo4j.com/docs/cypher-manual/current/functions/aggregating/#grouping-keys). +The usage of `GROUP BY` in the above nGQL statements that explicitly write `GROUP BY` and acts as grouping fields is called explicit `GROUP BY`, while in openCypher, the `GROUP BY` is implicit, i.e., `GROUP BY` groups fields without explicitly writing `GROUP BY`. The explicit `GROUP BY` in nGQL is the same as the implicit `GROUP BY` in openCypher, and nGQL also supports the implicit `GROUP BY`. For the implicit usage of `GROUP BY`, see [how-to-make-group-by-in-a-cypher-query](https://stackoverflow.com/questions/52722671/how-to-make-group-by-in-a-cypher-query). For example, to look up the players over 34 years old with the same length of service, you can use the following statement: From ec76dedca5b01a28076c8fc7e35e044a9cd18841 Mon Sep 17 00:00:00 2001 From: Abby <78209557+abby-cyber@users.noreply.github.com> Date: Tue, 22 Nov 2022 16:21:46 +0800 Subject: [PATCH 3/3] Update group-by.md --- docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md index c0aa2890694..b5d28b3e8b0 100644 --- a/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md +++ b/docs-2.0/3.ngql-guide/8.clauses-and-options/group-by.md @@ -78,7 +78,7 @@ For more information about the `sum()` function, see [Built-in math functions](. ## Implicit GROUP BY -The usage of `GROUP BY` in the above nGQL statements that explicitly write `GROUP BY` and acts as grouping fields is called explicit `GROUP BY`, while in openCypher, the `GROUP BY` is implicit, i.e., `GROUP BY` groups fields without explicitly writing `GROUP BY`. The explicit `GROUP BY` in nGQL is the same as the implicit `GROUP BY` in openCypher, and nGQL also supports the implicit `GROUP BY`. For the implicit usage of `GROUP BY`, see [how-to-make-group-by-in-a-cypher-query](https://stackoverflow.com/questions/52722671/how-to-make-group-by-in-a-cypher-query). +The usage of `GROUP BY` in the above nGQL statements that explicitly write `GROUP BY` and act as grouping fields is called explicit `GROUP BY`, while in openCypher, the `GROUP BY` is implicit, i.e., `GROUP BY` groups fields without explicitly writing `GROUP BY`. The explicit `GROUP BY` in nGQL is the same as the implicit `GROUP BY` in openCypher, and nGQL also supports the implicit `GROUP BY`. For the implicit usage of `GROUP BY`, see [how-to-make-group-by-in-a-cypher-query](https://stackoverflow.com/questions/52722671/how-to-make-group-by-in-a-cypher-query). For example, to look up the players over 34 years old with the same length of service, you can use the following statement: