Skip to content

Commit cd7ec1a

Browse files
💬Generate LLM translations (#1684)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Quan <[email protected]>
1 parent 97da871 commit cd7ec1a

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

docs/cn/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-array-agg.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,35 @@ title: ARRAY_AGG
33
title_includes: LIST
44
---
55

6-
ARRAY_AGG 函数(也称为 LIST 别名)将查询结果中某一列的所有值(包括 NULL)转换为一个数组
6+
ARRAY_AGG 函数(也称为 LIST)将查询结果中特定列的所有值(包括 NULL)转换为数组
77

88
## 语法
99

1010
```sql
11-
ARRAY_AGG(<expr>)
11+
ARRAY_AGG(<expr>) [ WITHIN GROUP ( <orderby_clause> ) ]
1212

1313
LIST(<expr>)
1414
```
1515

1616
## 参数
1717

1818
| 参数 | 描述 |
19-
|-----------| ------------ |
19+
|-----------|--------------|
2020
| `<expr>` | 任何表达式 |
2121

22+
## 可选参数
23+
24+
| 可选参数 | 描述 |
25+
|-------------------------------------|------------------------------------------------|
26+
| WITHIN GROUP [&lt;orderby_clause&gt;](https://docs.databend.com/sql/sql-commands/query-syntax/query-select#order-by-clause) | 定义有序集合聚合中值的顺序 |
27+
2228
## 返回类型
2329

2430
返回一个 [Array](../../00-sql-reference/10-data-types/array.md),其元素类型与原始数据类型相同。
2531

2632
## 示例
2733

28-
以下示例展示了如何使用 ARRAY_AGG 函数将数据聚合并以方便的数组格式呈现:
34+
此示例展示了如何使用 ARRAY_AGG 函数将数据聚合并以方便的数组格式呈现:
2935

3036
```sql
3137
-- 创建表并插入示例数据
@@ -43,7 +49,7 @@ VALUES (1, 'Inception', 1, 5),
4349
(4, 'Interstellar', 1, 4),
4450
(5, 'Interstellar', 2, 3);
4551

46-
-- 将 Inception 的所有评分列出为一个数组
52+
-- 将 Inception 的所有评分列在数组中
4753
SELECT movie_title, ARRAY_AGG(rating) AS ratings
4854
FROM movie_ratings
4955
WHERE movie_title = 'Inception'
@@ -52,4 +58,14 @@ GROUP BY movie_title;
5258
| movie_title | ratings |
5359
|-------------|------------|
5460
| Inception | [5, 4, 5] |
61+
62+
-- 使用 `WITHIN GROUP` 将 Inception 的所有评分列在数组中
63+
SELECT movie_title, ARRAY_AGG(rating) WITHIN GROUP ( ORDER BY rating DESC ) AS ratings
64+
FROM movie_ratings
65+
WHERE movie_title = 'Inception'
66+
GROUP BY movie_title;
67+
68+
| movie_title | ratings |
69+
|-------------|------------|
70+
| Inception | [5, 5, 4] |
5571
```

docs/cn/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-string-agg.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ title: STRING_AGG
44

55
聚合函数。
66

7-
STRING_AGG() 函数将列中所有非 NULL 值转换为字符串,并使用分隔符分隔。
7+
STRING_AGG() 函数(也称为 GROUP_CONCAT 或 LISTAGG)将列中的所有非 NULL 值连接为一个字符串,并使用分隔符分隔。
88

99
## 语法
1010

11-
```sql
12-
STRING_AGG(<expr>)
13-
STRING_AGG(<expr> [, delimiter])
11+
```sql
12+
STRING_AGG(<expr> [, delimiter]) [ WITHIN GROUP ( <orderby_clause> ) ]
13+
GROUP_CONCAT(<expr> [, delimiter]) [ WITHIN GROUP ( <orderby_clause> ) ]
14+
LISTAGG(<expr> [, delimiter]) [ WITHIN GROUP ( <orderby_clause> ) ]
1415
```
1516

1617
:::info
@@ -29,10 +30,16 @@ SELECT string_agg(number::VARCHAR, '|') AS s FROM numbers(5);
2930

3031
## 参数
3132

32-
| 参数 | 描述 |
33-
|-------------|------------------------------------------------------------|
34-
| `<expr>` | 任何字符串表达式(如果不是字符串,使用 `::VARCHAR` 进行转换) |
35-
| `delimiter` | 可选的常量字符串,如果未指定,则使用空字符串 |
33+
| 参数 | 描述 |
34+
|------------|-------------------------------------------------------------|
35+
| `<expr>` | 任何字符串表达式(如果不是字符串,使用 `::VARCHAR` 进行转换) |
36+
37+
## 可选参数
38+
39+
| 可选参数 | 描述 |
40+
|-------------------------------------|------------------------------------------------------|
41+
| `delimiter` | 可选常量字符串,如果未指定,则使用空字符串 |
42+
| WITHIN GROUP [&lt;orderby_clause&gt;](https://docs.databend.com/sql/sql-commands/query-syntax/query-select#order-by-clause) | 定义有序集合聚合中值的顺序 |
3643

3744
## 返回类型
3845

@@ -64,7 +71,19 @@ FROM programming_languages;
6471

6572
**结果**
6673
```sql
67-
| concatenated_languages |
74+
| concatenated_languages |
75+
|------------------------------------------|
76+
| Python, JavaScript, Java, C#, Ruby |
77+
```
78+
79+
**查询示例:使用 `WITHIN GROUP` 按降序连接编程语言名称**
80+
```sql
81+
SELECT STRING_AGG(language_name, ', ') WITHIN GROUP ( ORDER BY language_name DESC ) AS concatenated_languages
82+
FROM programming_languages;
83+
```
84+
**结果**
85+
```sql
86+
| concatenated_languages |
6887
|------------------------------------------|
69-
| Python, JavaScript, Java, C#, Ruby |
88+
| Ruby, Python, JavaScript, Java, C# |
7089
```

0 commit comments

Comments
 (0)