Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move std() sum() to aggregating functions and add collect examples #1759

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
+-------------------------------+
```
```