From bc18a791a3a1c5e56f69f2b66ee63dafc14c6bf9 Mon Sep 17 00:00:00 2001 From: knqiufan <34114995+knqiufan@users.noreply.github.com> Date: Tue, 26 Dec 2023 01:06:15 +0800 Subject: [PATCH] add annotation to some examples of `aggregating` clause as titled --- .../6.functions-and-expressions/15.aggregating.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs-2.0-zh/3.ngql-guide/6.functions-and-expressions/15.aggregating.md b/docs-2.0-zh/3.ngql-guide/6.functions-and-expressions/15.aggregating.md index b810a118b8e..2391c307ca0 100644 --- a/docs-2.0-zh/3.ngql-guide/6.functions-and-expressions/15.aggregating.md +++ b/docs-2.0-zh/3.ngql-guide/6.functions-and-expressions/15.aggregating.md @@ -13,6 +13,7 @@ avg() 返回参数的平均值。 示例: ```ngql +# 返回 Tag player 的 age 属性的平均值。 nebula> MATCH (v:player) RETURN avg(v.player.age); +--------------------+ | avg(v.player.age) | @@ -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); +----------+----------+-------------------+ @@ -155,6 +157,7 @@ max() 返回参数的最大值。 示例: ```ngql +# 返回 Tag player 的 age 属性的最大值。 nebula> MATCH (v:player) RETURN max(v.player.age); +-------------------+ | max(v.player.age) | @@ -174,6 +177,7 @@ min() 返回参数的最小值。 示例: ```ngql +# 返回 Tag player 的 age 属性的最小值。 nebula> MATCH (v:player) RETURN min(v.player.age); +-------------------+ | min(v.player.age) | @@ -193,6 +197,7 @@ collect() 返回一个符合表达式返回结果的列表。该函数可以将 示例: ```ngql +# 将列表拆分为单独的行。 nebula> UNWIND [1, 2, 1] AS a \ RETURN a; +---+ @@ -203,6 +208,7 @@ nebula> UNWIND [1, 2, 1] AS a \ | 1 | +---+ +# 将列表拆分为单独的行记录后再合并为一个列表返回。 nebula> UNWIND [1, 2, 1] AS a \ RETURN collect(a); +------------+ @@ -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)); +---+------------+------------------+ @@ -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 \ @@ -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); +---------------------------------------------------------------+ @@ -261,6 +270,7 @@ nebula> MATCH (n:player) \ +-----+--------------------------------------------------------------------------+ ... +# 将 player100 的目的点 name 属性值聚合,结果合并为列表返回。 nebula> GO FROM "player100" OVER serve \ YIELD properties($$).name AS name \ | GROUP BY $-.name \ @@ -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 \ @@ -298,6 +309,7 @@ std() 返回参数的总体标准差。 示例: ```ngql +# 返回 Tag player 的 age 属性值的标准差。 nebula> MATCH (v:player) RETURN std(v.player.age); +-------------------+ | std(v.player.age) | @@ -317,6 +329,7 @@ sum() 返回参数的和。 示例: ```ngql +# 返回 Tag player 的 age 属性值的总和。 nebula> MATCH (v:player) RETURN sum(v.player.age); +-------------------+ | sum(v.player.age) | @@ -339,4 +352,4 @@ nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS dst, properties($$). | "player125" | 84.0 | | "player101" | 74.0 | +-------------+------------+ -``` \ No newline at end of file +```