diff --git a/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md b/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md index dba803880ccb2..dbad052708e67 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md +++ b/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md @@ -22,35 +22,76 @@ specific language governing permissions and limitations under the License. --> -## pmod +## Description -### description -#### Syntax +Returns the smallest positive solution of the modulo operation x mod y within the modular system, which is obtained by calculating (x % y + y) % y. + +## Syntax ```sql -BIGINT PMOD(BIGINT x, BIGINT y) -DOUBLE PMOD(DOUBLE x, DOUBLE y) +PMOD( , ) ``` -Returns the positive result of x mod y in the residue systems. -Formally, return `(x%y+y)%y`. -### example +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | Dividend | +| `` | Divisor should not be 0 | + +## Return value + +Returns an integer or a floating-point number. Special cases: + +- If x = 0, returns 0. +- If x is NULL or y is NULL, returns NULL. + +## Example +```sql +SELECT PMOD(13,5); ``` -MySQL [test]> SELECT PMOD(13,5); + +```text +-------------+ | pmod(13, 5) | +-------------+ | 3 | +-------------+ +``` -MySQL [test]> SELECT PMOD(-13,5); -+-------------+ +```sql +SELECT PMOD(-13,5); +``` + +```text ++--------------+ | pmod(-13, 5) | -+-------------+ -| 2 | -+-------------+ ++--------------+ +| 2 | ++--------------+ +``` + +```sql +SELECT PMOD(0,-12); +``` + +```text ++--------------+ +| pmod(0, -12) | ++--------------+ +| 0 | ++--------------+ +``` + +```sql +SELECT PMOD(0,null); ``` -### keywords - PMOD +```text ++-------------------------------+ +| pmod(cast(0 as DOUBLE), NULL) | ++-------------------------------+ +| NULL | ++-------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md b/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md index 5fe582bd9709e..75036bda315eb 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md +++ b/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md @@ -22,36 +22,62 @@ specific language governing permissions and limitations under the License. --> -## radians +## Description -### description -#### Syntax - -`DOUBLE radians(DOUBLE x)` Returns the value of `x` in radians, converted from degrees to radians. -### example +## Syntax +```sql +RADIANS() ``` -mysql> select radians(0); -+--------------+ -| radians(0.0) | -+--------------+ -| 0 | -+--------------+ -mysql> select radians(30); -+---------------------+ -| radians(30.0) | -+---------------------+ -| 0.52359877559829882 | -+---------------------+ -mysql> select radians(90); -+--------------------+ -| radians(90.0) | -+--------------------+ -| 1.5707963267948966 | -+--------------------+ + +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | The angle in degrees to be converted. | + +## Return value + +Returns an integer or a floating-point number. Special case: + +- If the parameter x is NULL, it returns NULL. + +## Example + +```sql +select radians(0); ``` -### keywords - RADIANS +```text ++----------------------------+ +| radians(cast(0 as DOUBLE)) | ++----------------------------+ +| 0.0 | ++----------------------------+ +``` + +```sql +select radians(30); +``` + +```text ++-----------------------------+ +| radians(cast(30 as DOUBLE)) | ++-----------------------------+ +| 0.5235987755982988 | ++-----------------------------+ +``` + +```sql +select radians(90); +``` + +```text ++-----------------------------+ +| radians(cast(90 as DOUBLE)) | ++-----------------------------+ +| 1.5707963267948966 | ++-----------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md b/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md index 722ff2e020e8a..4e1b283b684c2 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md +++ b/docs/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md @@ -22,58 +22,76 @@ specific language governing permissions and limitations under the License. --> -## random +## Description -### description -#### Syntax +Returns a random number between 0 and 1, or returns the required random number according to the parameters. -`DOUBLE random()` -Returns a random number between 0 and 1. +- Note: All parameters must be constants. -`DOUBLE random(DOUBLE seed)` -Returns a random number between 0 and 1, seeded with `seed`. +## Alias -`BIGINT random(BIGINT a, BIGINT b)` -Returns a random number between a and b. a must be less than b. +- RAND -Alias: `rand`. +## Syntax -Note: All parameters must be constants. +```sql +RANDOM() -- Generates a random number between 0 and 1 + +RANDOM() -- Generates a fixed sequence of random numbers between 0 and 1 based on the seed value + +RANDOM( , ) -- Generates a random number between a and b +``` + +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | random number generator seed. Returns a fixed sequence of random numbers between 0 and 1. | +| `` | The lower bound of a random number. | +| `` | The upper bound of a random number. It must be less than the lower bound. | + +## Return value -### example +- If no parameters are passed: Returns a random number between 0 and 1. + +- If a single parameter seed is passed: Returns a fixed sequence of random numbers between 0 and 1. + +- If two parameters a and b are passed: Returns a random integer between a and b. + +## Example ```sql -mysql> select random(); -+---------------------+ -| random() | -+---------------------+ -| 0.35446706030596947 | -+---------------------+ +select random(); +``` -mysql> select rand(1.2); -+---------------------+ -| rand(1) | -+---------------------+ -| 0.13387664401253274 | -+---------------------+ -1 row in set (0.13 sec) +```text ++--------------------+ +| random() | ++--------------------+ +| 0.8047437125910604 | ++--------------------+ +``` + +```sql +select rand(1.2); +``` -mysql> select rand(1.2); +```text +---------------------+ | rand(1) | +---------------------+ | 0.13387664401253274 | +---------------------+ -1 row in set (0.11 sec) +``` -mysql> select rand(-20, -10); +```sql +select rand(-20, -10); +``` + +```text +------------------+ | random(-20, -10) | +------------------+ -| -13 | +| -10 | +------------------+ -1 row in set (0.10 sec) ``` - -### keywords - RANDOM, RAND diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md index b744248091257..8837fffaed722 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md @@ -22,34 +22,76 @@ specific language governing permissions and limitations under the License. --> -## pmod - ## 描述 + +返回模运算 x mod y 在模系中的最小正数解,即通过计算 (x % y + y) % y 得出结果。 + ## 语法 ```sql -BIGINT PMOD(BIGINT x, BIGINT y) -DOUBLE PMOD(DOUBLE x, DOUBLE y) +PMOD( , ) ``` -返回在模系下`x mod y`的最小正数解. -具体地来说, 返回 `(x%y+y)%y`. + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 被除数 | +| `` | 除数 不能为0 | + +## 返回值 + +返回一个整型或浮点数。特殊情况: + +- 当 x=0 时,返回0。 +- 当 x is NULL 或 y is NULL时,返回NULL。 ## 举例 +```sql +SELECT PMOD(13,5); ``` -MySQL [test]> SELECT PMOD(13,5); + +```text +-------------+ | pmod(13, 5) | +-------------+ | 3 | +-------------+ -MySQL [test]> SELECT PMOD(-13,5); -+-------------+ +``` + +```sql +SELECT PMOD(-13,5); +``` + +```text ++--------------+ | pmod(-13, 5) | -+-------------+ -| 2 | -+-------------+ ++--------------+ +| 2 | ++--------------+ +``` + +```sql +SELECT PMOD(0,-12); +``` + +```text ++--------------+ +| pmod(0, -12) | ++--------------+ +| 0 | ++--------------+ +``` + +```sql +SELECT PMOD(0,null); ``` -### keywords - PMOD +```text ++-------------------------------+ +| pmod(cast(0 as DOUBLE), NULL) | ++-------------------------------+ +| NULL | ++-------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md index aca3245faf7cf..691e0a1d3b071 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md @@ -22,36 +22,62 @@ specific language governing permissions and limitations under the License. --> -## radians - ## 描述 -## 语法 -`DOUBLE radians(DOUBLE x)` 返回`x`的弧度值, 从度转换为弧度. +## 语法 + +```sql +RADIANS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算的从度 | + +## 返回值 + +返回一个整型或者浮点数。特殊情况: + +- 当参数 x is NULL,返回 NULL + ## 举例 +```sql +select radians(0); ``` -mysql> select radians(0); -+--------------+ -| radians(0.0) | -+--------------+ -| 0 | -+--------------+ -mysql> select radians(30); -+---------------------+ -| radians(30.0) | -+---------------------+ -| 0.52359877559829882 | -+---------------------+ -mysql> select radians(90); -+--------------------+ -| radians(90.0) | -+--------------------+ -| 1.5707963267948966 | -+--------------------+ + +```text ++----------------------------+ +| radians(cast(0 as DOUBLE)) | ++----------------------------+ +| 0.0 | ++----------------------------+ ``` -### keywords - RADIANS +```sql +select radians(30); +``` + +```text ++-----------------------------+ +| radians(cast(30 as DOUBLE)) | ++-----------------------------+ +| 0.5235987755982988 | ++-----------------------------+ +``` + +```sql +select radians(90); +``` + +```text ++-----------------------------+ +| radians(cast(90 as DOUBLE)) | ++-----------------------------+ +| 1.5707963267948966 | ++-----------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md index ed08dd77aacdb..8853401531723 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md @@ -22,58 +22,76 @@ specific language governing permissions and limitations under the License. --> -## random - ## 描述 + +返回0-1之间的随机数,或者根据参数返回需要的随机数。 + +- 注意:所有参数必须为常量。 + +## 别名 + +- RAND + ## 语法 -`DOUBLE random()` -返回0-1之间的随机数。 +```sql +RANDOM() --生成0-1之间的随机数 -`DOUBLE random(DOUBLE seed)` -返回0-1之间的随机数,以`seed`作为种子。 +RANDOM() --根据seed种子值,生成一个0-1之间的固定随机数序列 -`BIGINT random(BIGINT a, BIGINT b)` -返回a-b之间的随机数,a必须小于b。 +RANDOM( , ) --生成a-b之间的随机数 +``` -别名:`rand` +## 参数 -注意:所有参数必须为常量。 +| 参数 | 说明 | +| -- | -- | +| `` | 随机数生成器的种子值 根据种子值返回一个0-1之间的固定随机数序列 | +| `` | 随机数的下限 | +| `` | 随机数的上限 必须小于下限 | + +## 返回值 + +- 不传参时:返回0-1之间的随机数。 + +- 传入单个参数`seed`时:根据传入的种子值`seed`,返回一个0-1之间的固定随机数序列。 + +- 传入两个参数`a`和`b`时:返回a-b之间的随机整数. ## 举例 ```sql -mysql> select random(); -+---------------------+ -| random() | -+---------------------+ -| 0.35446706030596947 | -+---------------------+ +select random(); +``` -mysql> select rand(1.2); -+---------------------+ -| rand(1) | -+---------------------+ -| 0.13387664401253274 | -+---------------------+ -1 row in set (0.13 sec) +```text ++--------------------+ +| random() | ++--------------------+ +| 0.8047437125910604 | ++--------------------+ +``` -mysql> select rand(1.2); +```sql +select rand(1.2); +``` + +```text +---------------------+ | rand(1) | +---------------------+ | 0.13387664401253274 | +---------------------+ -1 row in set (0.11 sec) +``` -mysql> select rand(-20, -10); +```sql +select rand(-20, -10); +``` + +```text +------------------+ | random(-20, -10) | +------------------+ -| -13 | +| -10 | +------------------+ -1 row in set (0.10 sec) ``` - -### keywords - RANDOM, RAND diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md index b744248091257..8837fffaed722 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md @@ -22,34 +22,76 @@ specific language governing permissions and limitations under the License. --> -## pmod - ## 描述 + +返回模运算 x mod y 在模系中的最小正数解,即通过计算 (x % y + y) % y 得出结果。 + ## 语法 ```sql -BIGINT PMOD(BIGINT x, BIGINT y) -DOUBLE PMOD(DOUBLE x, DOUBLE y) +PMOD( , ) ``` -返回在模系下`x mod y`的最小正数解. -具体地来说, 返回 `(x%y+y)%y`. + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 被除数 | +| `` | 除数 不能为0 | + +## 返回值 + +返回一个整型或浮点数。特殊情况: + +- 当 x=0 时,返回0。 +- 当 x is NULL 或 y is NULL时,返回NULL。 ## 举例 +```sql +SELECT PMOD(13,5); ``` -MySQL [test]> SELECT PMOD(13,5); + +```text +-------------+ | pmod(13, 5) | +-------------+ | 3 | +-------------+ -MySQL [test]> SELECT PMOD(-13,5); -+-------------+ +``` + +```sql +SELECT PMOD(-13,5); +``` + +```text ++--------------+ | pmod(-13, 5) | -+-------------+ -| 2 | -+-------------+ ++--------------+ +| 2 | ++--------------+ +``` + +```sql +SELECT PMOD(0,-12); +``` + +```text ++--------------+ +| pmod(0, -12) | ++--------------+ +| 0 | ++--------------+ +``` + +```sql +SELECT PMOD(0,null); ``` -### keywords - PMOD +```text ++-------------------------------+ +| pmod(cast(0 as DOUBLE), NULL) | ++-------------------------------+ +| NULL | ++-------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md index aca3245faf7cf..691e0a1d3b071 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md @@ -22,36 +22,62 @@ specific language governing permissions and limitations under the License. --> -## radians - ## 描述 -## 语法 -`DOUBLE radians(DOUBLE x)` 返回`x`的弧度值, 从度转换为弧度. +## 语法 + +```sql +RADIANS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算的从度 | + +## 返回值 + +返回一个整型或者浮点数。特殊情况: + +- 当参数 x is NULL,返回 NULL + ## 举例 +```sql +select radians(0); ``` -mysql> select radians(0); -+--------------+ -| radians(0.0) | -+--------------+ -| 0 | -+--------------+ -mysql> select radians(30); -+---------------------+ -| radians(30.0) | -+---------------------+ -| 0.52359877559829882 | -+---------------------+ -mysql> select radians(90); -+--------------------+ -| radians(90.0) | -+--------------------+ -| 1.5707963267948966 | -+--------------------+ + +```text ++----------------------------+ +| radians(cast(0 as DOUBLE)) | ++----------------------------+ +| 0.0 | ++----------------------------+ ``` -### keywords - RADIANS +```sql +select radians(30); +``` + +```text ++-----------------------------+ +| radians(cast(30 as DOUBLE)) | ++-----------------------------+ +| 0.5235987755982988 | ++-----------------------------+ +``` + +```sql +select radians(90); +``` + +```text ++-----------------------------+ +| radians(cast(90 as DOUBLE)) | ++-----------------------------+ +| 1.5707963267948966 | ++-----------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md index ed08dd77aacdb..8853401531723 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md @@ -22,58 +22,76 @@ specific language governing permissions and limitations under the License. --> -## random - ## 描述 + +返回0-1之间的随机数,或者根据参数返回需要的随机数。 + +- 注意:所有参数必须为常量。 + +## 别名 + +- RAND + ## 语法 -`DOUBLE random()` -返回0-1之间的随机数。 +```sql +RANDOM() --生成0-1之间的随机数 -`DOUBLE random(DOUBLE seed)` -返回0-1之间的随机数,以`seed`作为种子。 +RANDOM() --根据seed种子值,生成一个0-1之间的固定随机数序列 -`BIGINT random(BIGINT a, BIGINT b)` -返回a-b之间的随机数,a必须小于b。 +RANDOM( , ) --生成a-b之间的随机数 +``` -别名:`rand` +## 参数 -注意:所有参数必须为常量。 +| 参数 | 说明 | +| -- | -- | +| `` | 随机数生成器的种子值 根据种子值返回一个0-1之间的固定随机数序列 | +| `` | 随机数的下限 | +| `` | 随机数的上限 必须小于下限 | + +## 返回值 + +- 不传参时:返回0-1之间的随机数。 + +- 传入单个参数`seed`时:根据传入的种子值`seed`,返回一个0-1之间的固定随机数序列。 + +- 传入两个参数`a`和`b`时:返回a-b之间的随机整数. ## 举例 ```sql -mysql> select random(); -+---------------------+ -| random() | -+---------------------+ -| 0.35446706030596947 | -+---------------------+ +select random(); +``` -mysql> select rand(1.2); -+---------------------+ -| rand(1) | -+---------------------+ -| 0.13387664401253274 | -+---------------------+ -1 row in set (0.13 sec) +```text ++--------------------+ +| random() | ++--------------------+ +| 0.8047437125910604 | ++--------------------+ +``` -mysql> select rand(1.2); +```sql +select rand(1.2); +``` + +```text +---------------------+ | rand(1) | +---------------------+ | 0.13387664401253274 | +---------------------+ -1 row in set (0.11 sec) +``` -mysql> select rand(-20, -10); +```sql +select rand(-20, -10); +``` + +```text +------------------+ | random(-20, -10) | +------------------+ -| -13 | +| -10 | +------------------+ -1 row in set (0.10 sec) ``` - -### keywords - RANDOM, RAND diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md index b744248091257..8837fffaed722 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md @@ -22,34 +22,76 @@ specific language governing permissions and limitations under the License. --> -## pmod - ## 描述 + +返回模运算 x mod y 在模系中的最小正数解,即通过计算 (x % y + y) % y 得出结果。 + ## 语法 ```sql -BIGINT PMOD(BIGINT x, BIGINT y) -DOUBLE PMOD(DOUBLE x, DOUBLE y) +PMOD( , ) ``` -返回在模系下`x mod y`的最小正数解. -具体地来说, 返回 `(x%y+y)%y`. + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 被除数 | +| `` | 除数 不能为0 | + +## 返回值 + +返回一个整型或浮点数。特殊情况: + +- 当 x=0 时,返回0。 +- 当 x is NULL 或 y is NULL时,返回NULL。 ## 举例 +```sql +SELECT PMOD(13,5); ``` -MySQL [test]> SELECT PMOD(13,5); + +```text +-------------+ | pmod(13, 5) | +-------------+ | 3 | +-------------+ -MySQL [test]> SELECT PMOD(-13,5); -+-------------+ +``` + +```sql +SELECT PMOD(-13,5); +``` + +```text ++--------------+ | pmod(-13, 5) | -+-------------+ -| 2 | -+-------------+ ++--------------+ +| 2 | ++--------------+ +``` + +```sql +SELECT PMOD(0,-12); +``` + +```text ++--------------+ +| pmod(0, -12) | ++--------------+ +| 0 | ++--------------+ +``` + +```sql +SELECT PMOD(0,null); ``` -### keywords - PMOD +```text ++-------------------------------+ +| pmod(cast(0 as DOUBLE), NULL) | ++-------------------------------+ +| NULL | ++-------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md index aca3245faf7cf..691e0a1d3b071 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md @@ -22,36 +22,62 @@ specific language governing permissions and limitations under the License. --> -## radians - ## 描述 -## 语法 -`DOUBLE radians(DOUBLE x)` 返回`x`的弧度值, 从度转换为弧度. +## 语法 + +```sql +RADIANS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算的从度 | + +## 返回值 + +返回一个整型或者浮点数。特殊情况: + +- 当参数 x is NULL,返回 NULL + ## 举例 +```sql +select radians(0); ``` -mysql> select radians(0); -+--------------+ -| radians(0.0) | -+--------------+ -| 0 | -+--------------+ -mysql> select radians(30); -+---------------------+ -| radians(30.0) | -+---------------------+ -| 0.52359877559829882 | -+---------------------+ -mysql> select radians(90); -+--------------------+ -| radians(90.0) | -+--------------------+ -| 1.5707963267948966 | -+--------------------+ + +```text ++----------------------------+ +| radians(cast(0 as DOUBLE)) | ++----------------------------+ +| 0.0 | ++----------------------------+ ``` -### keywords - RADIANS +```sql +select radians(30); +``` + +```text ++-----------------------------+ +| radians(cast(30 as DOUBLE)) | ++-----------------------------+ +| 0.5235987755982988 | ++-----------------------------+ +``` + +```sql +select radians(90); +``` + +```text ++-----------------------------+ +| radians(cast(90 as DOUBLE)) | ++-----------------------------+ +| 1.5707963267948966 | ++-----------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md index ed08dd77aacdb..8853401531723 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md @@ -22,58 +22,76 @@ specific language governing permissions and limitations under the License. --> -## random - ## 描述 + +返回0-1之间的随机数,或者根据参数返回需要的随机数。 + +- 注意:所有参数必须为常量。 + +## 别名 + +- RAND + ## 语法 -`DOUBLE random()` -返回0-1之间的随机数。 +```sql +RANDOM() --生成0-1之间的随机数 -`DOUBLE random(DOUBLE seed)` -返回0-1之间的随机数,以`seed`作为种子。 +RANDOM() --根据seed种子值,生成一个0-1之间的固定随机数序列 -`BIGINT random(BIGINT a, BIGINT b)` -返回a-b之间的随机数,a必须小于b。 +RANDOM( , ) --生成a-b之间的随机数 +``` -别名:`rand` +## 参数 -注意:所有参数必须为常量。 +| 参数 | 说明 | +| -- | -- | +| `` | 随机数生成器的种子值 根据种子值返回一个0-1之间的固定随机数序列 | +| `` | 随机数的下限 | +| `` | 随机数的上限 必须小于下限 | + +## 返回值 + +- 不传参时:返回0-1之间的随机数。 + +- 传入单个参数`seed`时:根据传入的种子值`seed`,返回一个0-1之间的固定随机数序列。 + +- 传入两个参数`a`和`b`时:返回a-b之间的随机整数. ## 举例 ```sql -mysql> select random(); -+---------------------+ -| random() | -+---------------------+ -| 0.35446706030596947 | -+---------------------+ +select random(); +``` -mysql> select rand(1.2); -+---------------------+ -| rand(1) | -+---------------------+ -| 0.13387664401253274 | -+---------------------+ -1 row in set (0.13 sec) +```text ++--------------------+ +| random() | ++--------------------+ +| 0.8047437125910604 | ++--------------------+ +``` -mysql> select rand(1.2); +```sql +select rand(1.2); +``` + +```text +---------------------+ | rand(1) | +---------------------+ | 0.13387664401253274 | +---------------------+ -1 row in set (0.11 sec) +``` -mysql> select rand(-20, -10); +```sql +select rand(-20, -10); +``` + +```text +------------------+ | random(-20, -10) | +------------------+ -| -13 | +| -10 | +------------------+ -1 row in set (0.10 sec) ``` - -### keywords - RANDOM, RAND diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md index dba803880ccb2..dbad052708e67 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md @@ -22,35 +22,76 @@ specific language governing permissions and limitations under the License. --> -## pmod +## Description -### description -#### Syntax +Returns the smallest positive solution of the modulo operation x mod y within the modular system, which is obtained by calculating (x % y + y) % y. + +## Syntax ```sql -BIGINT PMOD(BIGINT x, BIGINT y) -DOUBLE PMOD(DOUBLE x, DOUBLE y) +PMOD( , ) ``` -Returns the positive result of x mod y in the residue systems. -Formally, return `(x%y+y)%y`. -### example +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | Dividend | +| `` | Divisor should not be 0 | + +## Return value + +Returns an integer or a floating-point number. Special cases: + +- If x = 0, returns 0. +- If x is NULL or y is NULL, returns NULL. + +## Example +```sql +SELECT PMOD(13,5); ``` -MySQL [test]> SELECT PMOD(13,5); + +```text +-------------+ | pmod(13, 5) | +-------------+ | 3 | +-------------+ +``` -MySQL [test]> SELECT PMOD(-13,5); -+-------------+ +```sql +SELECT PMOD(-13,5); +``` + +```text ++--------------+ | pmod(-13, 5) | -+-------------+ -| 2 | -+-------------+ ++--------------+ +| 2 | ++--------------+ +``` + +```sql +SELECT PMOD(0,-12); +``` + +```text ++--------------+ +| pmod(0, -12) | ++--------------+ +| 0 | ++--------------+ +``` + +```sql +SELECT PMOD(0,null); ``` -### keywords - PMOD +```text ++-------------------------------+ +| pmod(cast(0 as DOUBLE), NULL) | ++-------------------------------+ +| NULL | ++-------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md index 5fe582bd9709e..75036bda315eb 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md @@ -22,36 +22,62 @@ specific language governing permissions and limitations under the License. --> -## radians +## Description -### description -#### Syntax - -`DOUBLE radians(DOUBLE x)` Returns the value of `x` in radians, converted from degrees to radians. -### example +## Syntax +```sql +RADIANS() ``` -mysql> select radians(0); -+--------------+ -| radians(0.0) | -+--------------+ -| 0 | -+--------------+ -mysql> select radians(30); -+---------------------+ -| radians(30.0) | -+---------------------+ -| 0.52359877559829882 | -+---------------------+ -mysql> select radians(90); -+--------------------+ -| radians(90.0) | -+--------------------+ -| 1.5707963267948966 | -+--------------------+ + +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | The angle in degrees to be converted. | + +## Return value + +Returns an integer or a floating-point number. Special case: + +- If the parameter x is NULL, it returns NULL. + +## Example + +```sql +select radians(0); ``` -### keywords - RADIANS +```text ++----------------------------+ +| radians(cast(0 as DOUBLE)) | ++----------------------------+ +| 0.0 | ++----------------------------+ +``` + +```sql +select radians(30); +``` + +```text ++-----------------------------+ +| radians(cast(30 as DOUBLE)) | ++-----------------------------+ +| 0.5235987755982988 | ++-----------------------------+ +``` + +```sql +select radians(90); +``` + +```text ++-----------------------------+ +| radians(cast(90 as DOUBLE)) | ++-----------------------------+ +| 1.5707963267948966 | ++-----------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md index 722ff2e020e8a..4e1b283b684c2 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md @@ -22,58 +22,76 @@ specific language governing permissions and limitations under the License. --> -## random +## Description -### description -#### Syntax +Returns a random number between 0 and 1, or returns the required random number according to the parameters. -`DOUBLE random()` -Returns a random number between 0 and 1. +- Note: All parameters must be constants. -`DOUBLE random(DOUBLE seed)` -Returns a random number between 0 and 1, seeded with `seed`. +## Alias -`BIGINT random(BIGINT a, BIGINT b)` -Returns a random number between a and b. a must be less than b. +- RAND -Alias: `rand`. +## Syntax -Note: All parameters must be constants. +```sql +RANDOM() -- Generates a random number between 0 and 1 + +RANDOM() -- Generates a fixed sequence of random numbers between 0 and 1 based on the seed value + +RANDOM( , ) -- Generates a random number between a and b +``` + +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | random number generator seed. Returns a fixed sequence of random numbers between 0 and 1. | +| `` | The lower bound of a random number. | +| `` | The upper bound of a random number. It must be less than the lower bound. | + +## Return value -### example +- If no parameters are passed: Returns a random number between 0 and 1. + +- If a single parameter seed is passed: Returns a fixed sequence of random numbers between 0 and 1. + +- If two parameters a and b are passed: Returns a random integer between a and b. + +## Example ```sql -mysql> select random(); -+---------------------+ -| random() | -+---------------------+ -| 0.35446706030596947 | -+---------------------+ +select random(); +``` -mysql> select rand(1.2); -+---------------------+ -| rand(1) | -+---------------------+ -| 0.13387664401253274 | -+---------------------+ -1 row in set (0.13 sec) +```text ++--------------------+ +| random() | ++--------------------+ +| 0.8047437125910604 | ++--------------------+ +``` + +```sql +select rand(1.2); +``` -mysql> select rand(1.2); +```text +---------------------+ | rand(1) | +---------------------+ | 0.13387664401253274 | +---------------------+ -1 row in set (0.11 sec) +``` -mysql> select rand(-20, -10); +```sql +select rand(-20, -10); +``` + +```text +------------------+ | random(-20, -10) | +------------------+ -| -13 | +| -10 | +------------------+ -1 row in set (0.10 sec) ``` - -### keywords - RANDOM, RAND diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md index dba803880ccb2..dbad052708e67 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/pmod.md @@ -22,35 +22,76 @@ specific language governing permissions and limitations under the License. --> -## pmod +## Description -### description -#### Syntax +Returns the smallest positive solution of the modulo operation x mod y within the modular system, which is obtained by calculating (x % y + y) % y. + +## Syntax ```sql -BIGINT PMOD(BIGINT x, BIGINT y) -DOUBLE PMOD(DOUBLE x, DOUBLE y) +PMOD( , ) ``` -Returns the positive result of x mod y in the residue systems. -Formally, return `(x%y+y)%y`. -### example +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | Dividend | +| `` | Divisor should not be 0 | + +## Return value + +Returns an integer or a floating-point number. Special cases: + +- If x = 0, returns 0. +- If x is NULL or y is NULL, returns NULL. + +## Example +```sql +SELECT PMOD(13,5); ``` -MySQL [test]> SELECT PMOD(13,5); + +```text +-------------+ | pmod(13, 5) | +-------------+ | 3 | +-------------+ +``` -MySQL [test]> SELECT PMOD(-13,5); -+-------------+ +```sql +SELECT PMOD(-13,5); +``` + +```text ++--------------+ | pmod(-13, 5) | -+-------------+ -| 2 | -+-------------+ ++--------------+ +| 2 | ++--------------+ +``` + +```sql +SELECT PMOD(0,-12); +``` + +```text ++--------------+ +| pmod(0, -12) | ++--------------+ +| 0 | ++--------------+ +``` + +```sql +SELECT PMOD(0,null); ``` -### keywords - PMOD +```text ++-------------------------------+ +| pmod(cast(0 as DOUBLE), NULL) | ++-------------------------------+ +| NULL | ++-------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md index 5fe582bd9709e..75036bda315eb 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/radians.md @@ -22,36 +22,62 @@ specific language governing permissions and limitations under the License. --> -## radians +## Description -### description -#### Syntax - -`DOUBLE radians(DOUBLE x)` Returns the value of `x` in radians, converted from degrees to radians. -### example +## Syntax +```sql +RADIANS() ``` -mysql> select radians(0); -+--------------+ -| radians(0.0) | -+--------------+ -| 0 | -+--------------+ -mysql> select radians(30); -+---------------------+ -| radians(30.0) | -+---------------------+ -| 0.52359877559829882 | -+---------------------+ -mysql> select radians(90); -+--------------------+ -| radians(90.0) | -+--------------------+ -| 1.5707963267948966 | -+--------------------+ + +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | The angle in degrees to be converted. | + +## Return value + +Returns an integer or a floating-point number. Special case: + +- If the parameter x is NULL, it returns NULL. + +## Example + +```sql +select radians(0); ``` -### keywords - RADIANS +```text ++----------------------------+ +| radians(cast(0 as DOUBLE)) | ++----------------------------+ +| 0.0 | ++----------------------------+ +``` + +```sql +select radians(30); +``` + +```text ++-----------------------------+ +| radians(cast(30 as DOUBLE)) | ++-----------------------------+ +| 0.5235987755982988 | ++-----------------------------+ +``` + +```sql +select radians(90); +``` + +```text ++-----------------------------+ +| radians(cast(90 as DOUBLE)) | ++-----------------------------+ +| 1.5707963267948966 | ++-----------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md index 722ff2e020e8a..4e1b283b684c2 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/numeric-functions/random.md @@ -22,58 +22,76 @@ specific language governing permissions and limitations under the License. --> -## random +## Description -### description -#### Syntax +Returns a random number between 0 and 1, or returns the required random number according to the parameters. -`DOUBLE random()` -Returns a random number between 0 and 1. +- Note: All parameters must be constants. -`DOUBLE random(DOUBLE seed)` -Returns a random number between 0 and 1, seeded with `seed`. +## Alias -`BIGINT random(BIGINT a, BIGINT b)` -Returns a random number between a and b. a must be less than b. +- RAND -Alias: `rand`. +## Syntax -Note: All parameters must be constants. +```sql +RANDOM() -- Generates a random number between 0 and 1 + +RANDOM() -- Generates a fixed sequence of random numbers between 0 and 1 based on the seed value + +RANDOM( , ) -- Generates a random number between a and b +``` + +## Parameters + +| Parameter | Description | +|-----------|------------| +| `` | random number generator seed. Returns a fixed sequence of random numbers between 0 and 1. | +| `` | The lower bound of a random number. | +| `` | The upper bound of a random number. It must be less than the lower bound. | + +## Return value -### example +- If no parameters are passed: Returns a random number between 0 and 1. + +- If a single parameter seed is passed: Returns a fixed sequence of random numbers between 0 and 1. + +- If two parameters a and b are passed: Returns a random integer between a and b. + +## Example ```sql -mysql> select random(); -+---------------------+ -| random() | -+---------------------+ -| 0.35446706030596947 | -+---------------------+ +select random(); +``` -mysql> select rand(1.2); -+---------------------+ -| rand(1) | -+---------------------+ -| 0.13387664401253274 | -+---------------------+ -1 row in set (0.13 sec) +```text ++--------------------+ +| random() | ++--------------------+ +| 0.8047437125910604 | ++--------------------+ +``` + +```sql +select rand(1.2); +``` -mysql> select rand(1.2); +```text +---------------------+ | rand(1) | +---------------------+ | 0.13387664401253274 | +---------------------+ -1 row in set (0.11 sec) +``` -mysql> select rand(-20, -10); +```sql +select rand(-20, -10); +``` + +```text +------------------+ | random(-20, -10) | +------------------+ -| -13 | +| -10 | +------------------+ -1 row in set (0.10 sec) ``` - -### keywords - RANDOM, RAND