Skip to content

Commit

Permalink
Move std() sum() to aggregating functions and add collect examples (#…
Browse files Browse the repository at this point in the history
…1759)

* move-std()-sum()-to-aggregating-functions-and-add-collect-examples

* Update 15.aggregating.md
  • Loading branch information
abby-cyber authored Nov 16, 2022
1 parent 016603a commit 65590f6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
58 changes: 42 additions & 16 deletions docs-2.0/3.ngql-guide/6.functions-and-expressions/15.aggregating.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,24 +257,32 @@ nebula> MATCH (n:player) \
| 25 | ["Joel Embiid", "Kyle Anderson"] |
+-----+--------------------------------------------------------------------------+
...
```
## Aggregating example
nebula> GO FROM "player100" OVER serve \
YIELD properties($$).name AS name \
| GROUP BY $-.name \
YIELD collect($-.name) AS name;
+-----------+
| name |
+-----------+
| ["Spurs"] |
+-----------+
```ngql
nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS dst, properties($$).age AS age \
| GROUP BY $-.dst \
YIELD \
$-.dst AS dst, \
toInteger((sum($-.age)/count($-.age)))+avg(distinct $-.age+1)+1 AS statistics;
+-------------+------------+
| dst | statistics |
+-------------+------------+
| "player125" | 84.0 |
| "player101" | 74.0 |
+-------------+------------+
```
nebula> LOOKUP ON player \
YIELD player.age As playerage \
| GROUP BY $-.playerage \
YIELD collect($-.playerage) AS playerage;
+------------------+
| playerage |
+------------------+
| [22] |
| [47] |
| [43] |
| [25, 25] |
+------------------+
...
```

## std()

Expand Down Expand Up @@ -312,4 +320,22 @@ nebula> MATCH (v:player) RETURN sum(v.player.age);
+-------------------+
| 1698 |
+-------------------+
```
```

## Aggregating example

```ngql
nebula> GO FROM "player100" OVER follow YIELD dst(edge) AS dst, properties($$).age AS age \
| GROUP BY $-.dst \
YIELD \
$-.dst AS dst, \
toInteger((sum($-.age)/count($-.age)))+avg(distinct $-.age+1)+1 AS statistics;
+-------------+------------+
| dst | statistics |
+-------------+------------+
| "player125" | 84.0 |
| "player101" | 74.0 |
+-------------+------------+
```


Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ nebula> YIELD hash(toLower("HELLO NEBULA"));
+-------------------------------+
| -8481157362655072082 |
+-------------------------------+
```
```

0 comments on commit 65590f6

Please sign in to comment.