Skip to content

Commit

Permalink
add annotation to some examples of aggregating clause (#2402)
Browse files Browse the repository at this point in the history
as titled
  • Loading branch information
knqiufan authored Dec 27, 2023
1 parent 01f80f9 commit 3c079b7
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ avg() 返回参数的平均值。
示例:

```ngql
# 返回 Tag player 的 age 属性的平均值。
nebula> MATCH (v:player) RETURN avg(v.player.age);
+--------------------+
| avg(v.player.age) |
Expand All @@ -38,6 +39,7 @@ count() 返回参数的数量。
示例:

```ngql
# 将列表拆分,并返回拆分后行的数量,列表元素的数量,拆分后将行去重后的数量。
nebula> WITH [NULL, 1, 1, 2, 2] As a UNWIND a AS b \
RETURN count(b), count(*), count(DISTINCT b);
+----------+----------+-------------------+
Expand Down Expand Up @@ -155,6 +157,7 @@ max() 返回参数的最大值。
示例:

```ngql
# 返回 Tag player 的 age 属性的最大值。
nebula> MATCH (v:player) RETURN max(v.player.age);
+-------------------+
| max(v.player.age) |
Expand All @@ -174,6 +177,7 @@ min() 返回参数的最小值。
示例:

```ngql
# 返回 Tag player 的 age 属性的最小值。
nebula> MATCH (v:player) RETURN min(v.player.age);
+-------------------+
| min(v.player.age) |
Expand All @@ -193,6 +197,7 @@ collect() 返回一个符合表达式返回结果的列表。该函数可以将
示例:

```ngql
# 将列表拆分为单独的行。
nebula> UNWIND [1, 2, 1] AS a \
RETURN a;
+---+
Expand All @@ -203,6 +208,7 @@ nebula> UNWIND [1, 2, 1] AS a \
| 1 |
+---+
# 将列表拆分为单独的行记录后再合并为一个列表返回。
nebula> UNWIND [1, 2, 1] AS a \
RETURN collect(a);
+------------+
Expand All @@ -211,6 +217,7 @@ nebula> UNWIND [1, 2, 1] AS a \
| [1, 2, 1] |
+------------+
# 统计并返回列表中相同元素的数量。
nebula> UNWIND [1, 2, 1] AS a \
RETURN a, collect(a), size(collect(a));
+---+------------+------------------+
Expand All @@ -231,6 +238,7 @@ nebula> UNWIND ["c", "b", "a", "d" ] AS p \
| ["d", "c", "b"] |
+-----------------+
# 将列表拆分后去重,再合并为新的列表返回。
nebula> WITH [1, 1, 2, 2] AS coll \
UNWIND coll AS x \
WITH DISTINCT x \
Expand All @@ -241,6 +249,7 @@ nebula> WITH [1, 1, 2, 2] AS coll \
| [1, 2] |
+--------+
# 将 Tag player 的 age 属性值合并为列表返回。
nebula> MATCH (n:player) \
RETURN collect(n.player.age);
+---------------------------------------------------------------+
Expand All @@ -261,6 +270,7 @@ nebula> MATCH (n:player) \
+-----+--------------------------------------------------------------------------+
...
# 将 player100 的目的点 name 属性值聚合,结果合并为列表返回。
nebula> GO FROM "player100" OVER serve \
YIELD properties($$).name AS name \
| GROUP BY $-.name \
Expand All @@ -271,6 +281,7 @@ nebula> GO FROM "player100" OVER serve \
| ["Spurs"] |
+-----------+
# 将 Tag player 的 age 属性值聚合,结果合并为列表返回。
nebula> LOOKUP ON player \
YIELD player.age As playerage \
| GROUP BY $-.playerage \
Expand Down Expand Up @@ -298,6 +309,7 @@ std() 返回参数的总体标准差。
示例:

```ngql
# 返回 Tag player 的 age 属性值的标准差。
nebula> MATCH (v:player) RETURN std(v.player.age);
+-------------------+
| std(v.player.age) |
Expand All @@ -317,6 +329,7 @@ sum() 返回参数的和。
示例:

```ngql
# 返回 Tag player 的 age 属性值的总和。
nebula> MATCH (v:player) RETURN sum(v.player.age);
+-------------------+
| sum(v.player.age) |
Expand All @@ -339,4 +352,4 @@ nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS dst, properties($$).
| "player125" | 84.0 |
| "player101" | 74.0 |
+-------------+------------+
```
```

0 comments on commit 3c079b7

Please sign in to comment.