-
Notifications
You must be signed in to change notification settings - Fork 387
[doc](agg) add doc for sem #3042
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| { | ||
| "title": "SEM", | ||
| "language": "en" | ||
| } | ||
| --- | ||
|
|
||
| ## Description | ||
|
|
||
| Calculate the standard error of the mean for all non-null values in the specified column or expression. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```text | ||
| SEM([DISTINCT] <expr>) | ||
| ``` | ||
|
|
||
| ## Parameters | ||
|
|
||
| | Parameter | Description | | ||
| | -- | -- | | ||
| | `<expr>` | An expression or column, typically a numeric column or an expression that can be converted to a numeric value, supporting the Double data type.| | ||
| | `[DISTINCT]` | An optional keyword indicating that the mean standard error should be calculated after removing duplicate values in expr.。 | | ||
|
|
||
| ## Return Value | ||
|
|
||
| Returns a Double. Returns the standard error of the mean for the selected column or expression. If all records within the group are NULL, the function returns NULL. | ||
|
|
||
| ## Examples | ||
|
|
||
| ```sql | ||
| -- setup | ||
| create table t1( | ||
| id int, | ||
| k_double double, | ||
| ) distributed by hash (id) buckets 1 | ||
| properties ("replication_num"="1"); | ||
| insert into t1 values | ||
| (1, 222.222), | ||
| (2, 3.3), | ||
| (3, 3.3), | ||
| (4, null); | ||
| ``` | ||
|
|
||
| ```sql | ||
| select sem(k_double) from t1; | ||
| ``` | ||
|
|
||
| Calculation of the mean for the Double type: the mean and standard error for [222.222, 3.3, 3.3, null] is 72.974. | ||
|
|
||
| ```text | ||
| +---------------+ | ||
| | sem(k_double) | | ||
| +---------------+ | ||
| | 72.974 | | ||
| +---------------+ | ||
| ``` | ||
|
|
||
| ```sql | ||
| select sem(cast(null as double)) from t1; | ||
| ``` | ||
|
|
||
| When all values are null, return null. | ||
|
|
||
| ```text | ||
| +---------------------------+ | ||
| | sem(cast(null as double)) | | ||
| +---------------------------+ | ||
| | NULL | | ||
| +---------------------------+ | ||
| ``` | ||
|
|
||
| ```sql | ||
| select sem(distinct k_double) from t1; | ||
| ``` | ||
|
|
||
| Using the DISTINCT keyword for deduplication calculations, the mean standard error after removing duplicates [222.222, 3.3, 3.3, null] is 109.461. | ||
|
|
||
| ```text | ||
| +------------------------+ | ||
| | sem(distinct k_double) | | ||
| +------------------------+ | ||
| | 109.461 | | ||
| +------------------------+ | ||
| ``` | ||
|
|
||
| ### Error example | ||
|
|
||
| ```sql | ||
| select sem(id) from t1; | ||
| ``` | ||
|
|
||
| ```text | ||
| ERROR 1105 (HY000): errCode = 2, detailMessage = sem only requires a double parameter: sem(id) | ||
| ``` |
95 changes: 95 additions & 0 deletions
95
...plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sem.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| --- | ||
| { | ||
| "title": "SEM", | ||
| "language": "zh-CN" | ||
| } | ||
| --- | ||
|
|
||
| ## 描述 | ||
|
|
||
| 计算指定列或表达式的所有非 NULL 值的均值标准误。 | ||
|
|
||
| ## 语法 | ||
|
|
||
| ```sql | ||
| SEM([DISTINCT] <expr>) | ||
| ``` | ||
|
|
||
| ## 参数 | ||
|
|
||
| | 参数 | 说明 | | ||
| | -- | -- | | ||
| | `<expr>` | 是一个表达式或列,通常是一个数值列或者能够转换为数值的表达式,支持类型为 Double。| | ||
| | `[DISTINCT]` | 是一个可选的关键字,表示对 expr 中的重复值进行去重后再计算均值标准误。 | | ||
|
|
||
| ## 返回值 | ||
|
|
||
| 返回值为 Double。 返回所选列或表达式的均值标准误,如果组内的所有记录均为 NULL,则该函数返回 NULL 。 | ||
|
|
||
| ## 举例 | ||
|
|
||
| ```sql | ||
| -- setup | ||
| create table t1( | ||
| id int, | ||
| k_double double, | ||
| ) distributed by hash (id) buckets 1 | ||
| properties ("replication_num"="1"); | ||
| insert into t1 values | ||
| (1, 222.222), | ||
| (2, 3.3), | ||
| (3, 3.3), | ||
| (4, null); | ||
| ``` | ||
|
|
||
| ```sql | ||
| select sem(k_double) from t1; | ||
| ``` | ||
|
|
||
| Double 类型的平均值计算,[222.222,3.3,3.3,null]的均值标准误为72.974。 | ||
|
|
||
| ```text | ||
| +---------------+ | ||
| | sem(k_double) | | ||
| +---------------+ | ||
| | 72.974 | | ||
| +---------------+ | ||
| ``` | ||
|
|
||
| ```sql | ||
| select sem(cast(null as double)) from t1; | ||
| ``` | ||
|
|
||
| 值全为null时,返回null。 | ||
|
|
||
| ```text | ||
| +---------------------------+ | ||
| | sem(cast(null as double)) | | ||
| +---------------------------+ | ||
| | NULL | | ||
| +---------------------------+ | ||
| ``` | ||
|
|
||
| ```sql | ||
| select sem(distinct k_double) from t1; | ||
| ``` | ||
|
|
||
| 使用 DISTINCT 关键字进行去重计算,[222.222,3.3,3.3,null]去重后均值标准误为109.461。 | ||
|
|
||
| ```text | ||
| +------------------------+ | ||
| | sem(distinct k_double) | | ||
| +------------------------+ | ||
| | 109.461 | | ||
| +------------------------+ | ||
| ``` | ||
|
|
||
| ### 错误示例 | ||
|
|
||
| ```sql | ||
| select sem(id) from t1; | ||
wumeibanfa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ```text | ||
| ERROR 1105 (HY000): errCode = 2, detailMessage = sem only requires a double parameter: sem(id) | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.