From 09cc385caabc63a6c8cbcfb4c56c6868406211ed Mon Sep 17 00:00:00 2001 From: HappenLee Date: Wed, 23 Nov 2022 16:22:57 +0800 Subject: [PATCH] [Docs](fucntion) Add docs for function random, mod, fmod (#14444) --- .../sql-functions/math-functions/mod.md | 55 +++++++++++++++++++ .../sql-functions/math-functions/random.md | 45 +++++++++++++++ docs/sidebars.json | 4 +- .../sql-functions/math-functions/mod.md | 55 +++++++++++++++++++ .../sql-functions/math-functions/random.md | 45 +++++++++++++++ 5 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 docs/en/docs/sql-manual/sql-functions/math-functions/mod.md create mode 100644 docs/en/docs/sql-manual/sql-functions/math-functions/random.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/math-functions/mod.md create mode 100644 docs/zh-CN/docs/sql-manual/sql-functions/math-functions/random.md diff --git a/docs/en/docs/sql-manual/sql-functions/math-functions/mod.md b/docs/en/docs/sql-manual/sql-functions/math-functions/mod.md new file mode 100644 index 0000000000..51ca55f705 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/math-functions/mod.md @@ -0,0 +1,55 @@ +--- +{ + "title": "mod", + "language": "en" +} +--- + + + +## mod + +### description +#### Syntax + +`mod(col_a, col_b)` + +`column` support type:`TINYINT` `SMALLINT` `INT` `BIGINT` `LARGEINT` `FLOAT` `DOUBLE` `DECIMAL` + +Find the remainder of a/b. For floating-point types, use the fmod function. + +### example + +``` +mysql> select mod(10, 3); ++------------+ +| mod(10, 3) | ++------------+ +| 1 | ++------------+ + +mysql> select fmod(10.1, 3.2); ++-----------------+ +| fmod(10.1, 3.2) | ++-----------------+ +| 0.50000024 | ++-----------------+ +``` + +### keywords + MOD,FMOD diff --git a/docs/en/docs/sql-manual/sql-functions/math-functions/random.md b/docs/en/docs/sql-manual/sql-functions/math-functions/random.md new file mode 100644 index 0000000000..00b1571b63 --- /dev/null +++ b/docs/en/docs/sql-manual/sql-functions/math-functions/random.md @@ -0,0 +1,45 @@ +--- +{ + "title": "random", + "language": "en" +} +--- + + + +## random + +### description +#### Syntax + +`DOUBLE random()` +Returns a random number between 0-1. + +### example + +``` +mysql> select random(); ++---------------------+ +| random() | ++---------------------+ +| 0.35446706030596947 | ++---------------------+ +``` + +### keywords + RANDOM diff --git a/docs/sidebars.json b/docs/sidebars.json index 535b5cbc5e..a19b322021 100644 --- a/docs/sidebars.json +++ b/docs/sidebars.json @@ -582,7 +582,9 @@ "sql-manual/sql-functions/math-functions/positive", "sql-manual/sql-functions/math-functions/negative", "sql-manual/sql-functions/math-functions/greatest", - "sql-manual/sql-functions/math-functions/least" + "sql-manual/sql-functions/math-functions/least", + "sql-manual/sql-functions/math-functions/random", + "sql-manual/sql-functions/math-functions/mod" ] }, { diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/math-functions/mod.md b/docs/zh-CN/docs/sql-manual/sql-functions/math-functions/mod.md new file mode 100644 index 0000000000..2165d1275b --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/math-functions/mod.md @@ -0,0 +1,55 @@ +--- +{ + "title": "mod", + "language": "zh-CN" +} +--- + + + +## mod + +### description +#### Syntax + +`mod(col_a, col_b)` + +`column`支持以下类型:`TINYINT` `SMALLINT` `INT` `BIGINT` `LARGEINT` `FLOAT` `DOUBLE` `DECIMAL` + +求a / b的余数。浮点类型请使用fmod函数。 + +### example + +``` +mysql> select mod(10, 3); ++------------+ +| mod(10, 3) | ++------------+ +| 1 | ++------------+ + +mysql> select fmod(10.1, 3.2); ++-----------------+ +| fmod(10.1, 3.2) | ++-----------------+ +| 0.50000024 | ++-----------------+ +``` + +### keywords + MOD,FMOD diff --git a/docs/zh-CN/docs/sql-manual/sql-functions/math-functions/random.md b/docs/zh-CN/docs/sql-manual/sql-functions/math-functions/random.md new file mode 100644 index 0000000000..be95837839 --- /dev/null +++ b/docs/zh-CN/docs/sql-manual/sql-functions/math-functions/random.md @@ -0,0 +1,45 @@ +--- +{ + "title": "random", + "language": "zh-CN" +} +--- + + + +## random + +### description +#### Syntax + +`DOUBLE random()` +返回0-1的随机数。 + +### example + +``` +mysql> select random(); ++---------------------+ +| random() | ++---------------------+ +| 0.35446706030596947 | ++---------------------+ +``` + +### keywords + RANDOM