[typo](docs) Add docs of math function (#12532)

* docs of math function
This commit is contained in:
TaoZex
2022-09-19 21:41:59 +08:00
committed by GitHub
parent 94d73abf2a
commit a5d11dce3b
57 changed files with 3168 additions and 1 deletions

View File

@ -0,0 +1,62 @@
---
{
"title": "abs",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## abs
### description
#### Syntax
`DOUBLE abs(DOUBLE x)` `SMALLINT abs(TINYINT x)` `INT abs(SMALLINT x)`
`BIGINT abs(INT x)` `LARGEINT abs(BIGINT x)` `LARGEINT abs(LARGEINT x)`
`DOUBLE abs(DOUBLE x)` `FLOAT abs(FLOAT x)` `DECIMAL abs(DECIMAL x)`
Returns the absolute value of `x`.
### example
```
mysql> select abs(-2);
+---------+
| abs(-2) |
+---------+
| 2 |
+---------+
mysql> select abs(3.254655654);
+------------------+
| abs(3.254655654) |
+------------------+
| 3.254655654 |
+------------------+
mysql> select abs(-3254654236547654354654767);
+---------------------------------+
| abs(-3254654236547654354654767) |
+---------------------------------+
| 3254654236547654354654767 |
+---------------------------------+
```
### keywords
ABS

View File

@ -0,0 +1,57 @@
---
{
"title": "acos",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## acos
### description
#### Syntax
`DOUBLE acos(DOUBLE x)`
Returns the arc cosine of `x`, or `nan` if `x` is not in the range `-1` to `1`.
### example
```
mysql> select acos(1);
+-----------+
| acos(1.0) |
+-----------+
| 0 |
+-----------+
mysql> select acos(0);
+--------------------+
| acos(0.0) |
+--------------------+
| 1.5707963267948966 |
+--------------------+
mysql> select acos(-2);
+------------+
| acos(-2.0) |
+------------+
| nan |
+------------+
```
### keywords
ACOS

View File

@ -0,0 +1,51 @@
---
{
"title": "asin",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## asin
### description
#### Syntax
`DOUBLE asin(DOUBLE x)`
Returns the arc sine of `x`, or `nan` if `x` is not in the range `-1` to `1`.
### example
```
mysql> select asin(0.5);
+---------------------+
| asin(0.5) |
+---------------------+
| 0.52359877559829893 |
+---------------------+
mysql> select asin(2);
+-----------+
| asin(2.0) |
+-----------+
| nan |
+-----------+
```
### keywords
ASIN

View File

@ -0,0 +1,51 @@
---
{
"title": "atan",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## atan
### description
#### Syntax
`DOUBLE atan(DOUBLE x)`
Returns the arctangent of `x`, where `x` is in radians.
### example
```
mysql> select atan(0);
+-----------+
| atan(0.0) |
+-----------+
| 0 |
+-----------+
mysql> select atan(2);
+--------------------+
| atan(2.0) |
+--------------------+
| 1.1071487177940904 |
+--------------------+
```
### keywords
ATAN

View File

@ -0,0 +1,57 @@
---
{
"title": "bin",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## bin
### description
#### Syntax
`STRING bin(BIGINT x)`
Convert the decimal number `x` to binary.
### example
```
mysql> select bin(0);
+--------+
| bin(0) |
+--------+
| 0 |
+--------+
mysql> select bin(10);
+---------+
| bin(10) |
+---------+
| 1010 |
+---------+
mysql> select bin(-3);
+------------------------------------------------------------------+
| bin(-3) |
+------------------------------------------------------------------+
| 1111111111111111111111111111111111111111111111111111111111111101 |
+------------------------------------------------------------------+
```
### keywords
BIN

View File

@ -0,0 +1,57 @@
---
{
"title": "ceil",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## ceil
### description
#### Syntax
`BIGINT ceil(DOUBLE x)`
Returns the smallest integer value greater than or equal to `x`.
### example
```
mysql> select ceil(1);
+-----------+
| ceil(1.0) |
+-----------+
| 1 |
+-----------+
mysql> select ceil(2.4);
+-----------+
| ceil(2.4) |
+-----------+
| 3 |
+-----------+
mysql> select ceil(-10.3);
+-------------+
| ceil(-10.3) |
+-------------+
| -10 |
+-------------+
```
### keywords
CEIL

View File

@ -0,0 +1,57 @@
---
{
"title": "cos",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## cos
### description
#### Syntax
`DOUBLE cos(DOUBLE x)`
Returns the cosine of `x`, where `x` is in radians
### example
```
mysql> select cos(1);
+---------------------+
| cos(1.0) |
+---------------------+
| 0.54030230586813977 |
+---------------------+
mysql> select cos(0);
+----------+
| cos(0.0) |
+----------+
| 1 |
+----------+
mysql> select cos(Pi());
+-----------+
| cos(pi()) |
+-----------+
| -1 |
+-----------+
```
### keywords
COS

View File

@ -0,0 +1,57 @@
---
{
"title": "degrees",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## degrees
### description
#### Syntax
`DOUBLE degrees(DOUBLE x)`
Returns the degree of `x`, converted from radians to degrees.
### example
```
mysql> select degrees(0);
+--------------+
| degrees(0.0) |
+--------------+
| 0 |
+--------------+
mysql> select degrees(2);
+--------------------+
| degrees(2.0) |
+--------------------+
| 114.59155902616465 |
+--------------------+
mysql> select degrees(Pi());
+---------------+
| degrees(pi()) |
+---------------+
| 180 |
+---------------+
```
### keywords
DEGREES

View File

@ -0,0 +1,45 @@
---
{
"title": "e",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## e
### description
#### Syntax
`DOUBLE e()`
Returns the constant `e` value.
### example
```
mysql> select e();
+--------------------+
| e() |
+--------------------+
| 2.7182818284590451 |
+--------------------+
```
### keywords
E

View File

@ -0,0 +1,51 @@
---
{
"title": "exp",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## exp
### description
#### Syntax
`DOUBLE exp(DOUBLE x)`
Returns `x` raised to the base `e`.
### example
```
mysql> select exp(2);
+------------------+
| exp(2.0) |
+------------------+
| 7.38905609893065 |
+------------------+
mysql> select exp(3.4);
+--------------------+
| exp(3.4) |
+--------------------+
| 29.964100047397011 |
+--------------------+
```
### keywords
EXP

View File

@ -0,0 +1,57 @@
---
{
"title": "floor",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## floor
### description
#### Syntax
`BIGINT floor(DOUBLE x)`
Returns the largest integer value less than or equal to `x`.
### example
```
mysql> select floor(1);
+------------+
| floor(1.0) |
+------------+
| 1 |
+------------+
mysql> select floor(2.4);
+------------+
| floor(2.4) |
+------------+
| 2 |
+------------+
mysql> select floor(-10.3);
+--------------+
| floor(-10.3) |
+--------------+
| -11 |
+--------------+
```
### keywords
FLOOR

View File

@ -0,0 +1,66 @@
---
{
"title": "greatest",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## greatest
### description
#### Syntax
`greatest(col_a, col_b, …, col_n)`
`column` supports the following types: `TINYINT` `SMALLINT` `INT` `BIGINT` `LARGEINT` `FLOAT` `DOUBLE` `STRING` `DATETIME` `DECIMAL`
Compares the size of `n columns` and returns the largest among them. If there is `NULL` in `column`, it returns `NULL`.
### example
```
mysql> select greatest(-1, 0, 5, 8);
+-----------------------+
| greatest(-1, 0, 5, 8) |
+-----------------------+
| 8 |
+-----------------------+
mysql> select greatest(-1, 0, 5, NULL);
+--------------------------+
| greatest(-1, 0, 5, NULL) |
+--------------------------+
| NULL |
+--------------------------+
mysql> select greatest(6.3, 4.29, 7.6876);
+-----------------------------+
| greatest(6.3, 4.29, 7.6876) |
+-----------------------------+
| 7.6876 |
+-----------------------------+
mysql> select greatest("2022-02-26 20:02:11","2020-01-23 20:02:11","2020-06-22 20:02:11");
+-------------------------------------------------------------------------------+
| greatest('2022-02-26 20:02:11', '2020-01-23 20:02:11', '2020-06-22 20:02:11') |
+-------------------------------------------------------------------------------+
| 2022-02-26 20:02:11 |
+-------------------------------------------------------------------------------+
```
### keywords
GREATEST

View File

@ -0,0 +1,66 @@
---
{
"title": "least",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## least
### description
#### Syntax
`least(col_a, col_b, …, col_n)`
`column` supports the following types: `TINYINT` `SMALLINT` `INT` `BIGINT` `LARGEINT` `FLOAT` `DOUBLE` `STRING` `DATETIME` `DECIMAL`
Compare the size of `n columns` and return the smallest among them. If there is `NULL` in `column`, return `NULL`.
### example
```
mysql> select least(-1, 0, 5, 8);
+--------------------+
| least(-1, 0, 5, 8) |
+--------------------+
| -1 |
+--------------------+
mysql> select least(-1, 0, 5, NULL);
+-----------------------+
| least(-1, 0, 5, NULL) |
+-----------------------+
| NULL |
+-----------------------+
mysql> select least(6.3, 4.29, 7.6876);
+--------------------------+
| least(6.3, 4.29, 7.6876) |
+--------------------------+
| 4.29 |
+--------------------------+
mysql> select least("2022-02-26 20:02:11","2020-01-23 20:02:11","2020-06-22 20:02:11");
+----------------------------------------------------------------------------+
| least('2022-02-26 20:02:11', '2020-01-23 20:02:11', '2020-06-22 20:02:11') |
+----------------------------------------------------------------------------+
| 2020-01-23 20:02:11 |
+----------------------------------------------------------------------------+
```
### keywords
LEAST

View File

@ -0,0 +1,57 @@
---
{
"title": "ln",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## ln
### description
#### Syntax
`DOUBLE ln(DOUBLE x)`
Returns the natural logarithm of `x` to base `e`.
### example
```
mysql> select ln(1);
+---------+
| ln(1.0) |
+---------+
| 0 |
+---------+
mysql> select ln(e());
+---------+
| ln(e()) |
+---------+
| 1 |
+---------+
mysql> select ln(10);
+--------------------+
| ln(10.0) |
+--------------------+
| 2.3025850929940459 |
+--------------------+
```
### keywords
LN

View File

@ -0,0 +1,57 @@
---
{
"title": "log",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## log
### description
#### Syntax
`DOUBLE log(DOUBLE b, DOUBLE x)`
Returns the logarithm of `x` based on base `b`.
### example
```
mysql> select log(5,1);
+---------------+
| log(5.0, 1.0) |
+---------------+
| 0 |
+---------------+
mysql> select log(3,20);
+--------------------+
| log(3.0, 20.0) |
+--------------------+
| 2.7268330278608417 |
+--------------------+
mysql> select log(2,65536);
+-------------------+
| log(2.0, 65536.0) |
+-------------------+
| 16 |
+-------------------+
```
### keywords
LOG

View File

@ -0,0 +1,57 @@
---
{
"title": "log10",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## log10
### description
#### Syntax
`DOUBLE log10(DOUBLE x)`
Returns the natural logarithm of `x` to base `10`.
### example
```
mysql> select log10(1);
+------------+
| log10(1.0) |
+------------+
| 0 |
+------------+
mysql> select log10(10);
+-------------+
| log10(10.0) |
+-------------+
| 1 |
+-------------+
mysql> select log10(16);
+--------------------+
| log10(16.0) |
+--------------------+
| 1.2041199826559248 |
+--------------------+
```
### keywords
LOG10

View File

@ -0,0 +1,57 @@
---
{
"title": "log2",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## log2
### description
#### Syntax
`DOUBLE log2(DOUBLE x)`
Returns the natural logarithm of `x` to base `2`.
### example
```
mysql> select log2(1);
+-----------+
| log2(1.0) |
+-----------+
| 0 |
+-----------+
mysql> select log2(2);
+-----------+
| log2(2.0) |
+-----------+
| 1 |
+-----------+
mysql> select log2(10);
+--------------------+
| log2(10.0) |
+--------------------+
| 3.3219280948873622 |
+--------------------+
```
### keywords
LOG2

View File

@ -0,0 +1,51 @@
---
{
"title": "negative",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## negative
### description
#### Syntax
`BIGINT negative(BIGINT x)` `DOUBLE negative(DOUBLE x)` `DECIMAL negative(DECIMAL x)`
Return `-x`.
### example
```
mysql> SELECT negative(-10);
+---------------+
| negative(-10) |
+---------------+
| 10 |
+---------------+
mysql> SELECT negative(12);
+--------------+
| negative(12) |
+--------------+
| -12 |
+--------------+
```
### keywords
NEGATIVE

View File

@ -0,0 +1,45 @@
---
{
"title": "Pi",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## Pi
### description
#### Syntax
`DOUBLE Pi()`
Returns the constant `Pi` value.
### example
```
mysql> select Pi();
+--------------------+
| pi() |
+--------------------+
| 3.1415926535897931 |
+--------------------+
```
### keywords
PI

View File

@ -0,0 +1,51 @@
---
{
"title": "positive",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## positive
### description
#### Syntax
`BIGINT positive(BIGINT x)` `DOUBLE positive(DOUBLE x)` `DECIMAL positive(DECIMAL x)`
Return `x`.
### example
```
mysql> SELECT positive(-10);
+---------------+
| positive(-10) |
+---------------+
| -10 |
+---------------+
mysql> SELECT positive(12);
+--------------+
| positive(12) |
+--------------+
| 12 |
+--------------+
```
### keywords
POSITIVE

View File

@ -0,0 +1,57 @@
---
{
"title": "pow",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## pow
### description
#### Syntax
`DOUBLE pow(DOUBLE a, DOUBLE b)`
Returns `a` raised to the `b` power.
### example
```
mysql> select pow(2,0);
+---------------+
| pow(2.0, 0.0) |
+---------------+
| 1 |
+---------------+
mysql> select pow(2,3);
+---------------+
| pow(2.0, 3.0) |
+---------------+
| 8 |
+---------------+
mysql> select pow(3,2.4);
+--------------------+
| pow(3.0, 2.4) |
+--------------------+
| 13.966610165238235 |
+--------------------+
```
### keywords
POW

View File

@ -0,0 +1,57 @@
---
{
"title": "radians",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## radians
### description
#### Syntax
`DOUBLE radians(DOUBLE x)`
Returns the value of `x` in radians, converted from degrees to radians.
### example
```
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 |
+--------------------+
```
### keywords
RADIANS

View File

@ -0,0 +1,63 @@
---
{
"title": "round",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## round
### description
#### Syntax
`BIGINT round(DOUBLE x)`
Preserve the integer part after rounding `x`
### example
```
mysql> select round(2.4);
+------------+
| round(2.4) |
+------------+
| 2 |
+------------+
mysql> select round(2.5);
+------------+
| round(2.5) |
+------------+
| 3 |
+------------+
mysql> select round(-3.4);
+-------------+
| round(-3.4) |
+-------------+
| -3 |
+-------------+
mysql> select round(-3.5);
+-------------+
| round(-3.5) |
+-------------+
| -4 |
+-------------+
```
### keywords
ROUND

View File

@ -0,0 +1,57 @@
---
{
"title": "sign",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## sign
### description
#### Syntax
`TINYINT sign(DOUBLE x)`
Returns the sign of `x`. Negative, zero or positive numbers correspond to -1, 0 or 1 respectively.
### example
```
mysql> select sign(3);
+-----------+
| sign(3.0) |
+-----------+
| 1 |
+-----------+
mysql> select sign(0);
+-----------+
| sign(0.0) |
+-----------+
| 0 |
mysql> select sign(-10.0);
+-------------+
| sign(-10.0) |
+-------------+
| -1 |
+-------------+
1 row in set (0.01 sec)
```
### keywords
SIGN

View File

@ -0,0 +1,57 @@
---
{
"title": "sin",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## sin
### description
#### Syntax
`DOUBLE sin(DOUBLE x)`
Returns the sine of `x`, where `x` is in radians
### example
```
mysql> select sin(0);
+----------+
| sin(0.0) |
+----------+
| 0 |
+----------+
mysql> select sin(1);
+--------------------+
| sin(1.0) |
+--------------------+
| 0.8414709848078965 |
+--------------------+
mysql> select sin(0.5 * Pi());
+-----------------+
| sin(0.5 * pi()) |
+-----------------+
| 1 |
+-----------------+
```
### keywords
SIN

View File

@ -0,0 +1,57 @@
---
{
"title": "sqrt",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## sqrt
### description
#### Syntax
`DOUBLE sqrt(DOUBLE x)`
Returns the square root of `x`.`x` is required to be greater than or equal to `0`.
### example
```
mysql> select sqrt(9);
+-----------+
| sqrt(9.0) |
+-----------+
| 3 |
+-----------+
mysql> select sqrt(2);
+--------------------+
| sqrt(2.0) |
+--------------------+
| 1.4142135623730951 |
+--------------------+
mysql> select sqrt(100.0);
+-------------+
| sqrt(100.0) |
+-------------+
| 10 |
+-------------+
```
### keywords
SQRT

View File

@ -0,0 +1,51 @@
---
{
"title": "tan",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## tan
### description
#### Syntax
`DOUBLE tan(DOUBLE x)`
Returns the tangent of `x`, where `x` is in radians.
### example
```
mysql> select tan(0);
+----------+
| tan(0.0) |
+----------+
| 0 |
+----------+
mysql> select tan(1);
+--------------------+
| tan(1.0) |
+--------------------+
| 1.5574077246549023 |
+--------------------+
```
### keywords
TAN

View File

@ -0,0 +1,62 @@
---
{
"title": "truncate",
"language": "en"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## truncate
### description
#### Syntax
`DOUBLE truncate(DOUBLE x, INT d)`
Numerically truncate `x` according to the number of decimal places `d`.
The rules are as follows:
When `d > 0`: keep `d` decimal places of `x`
When `d = 0`: remove the fractional part of `x` and keep only the integer part
When `d < 0`: Remove the fractional part of `x`, and replace the integer part with the number `0` according to the number of digits specified by `d`
### example
```
mysql> select truncate(124.3867, 2);
+-----------------------+
| truncate(124.3867, 2) |
+-----------------------+
| 124.38 |
+-----------------------+
mysql> select truncate(124.3867, 0);
+-----------------------+
| truncate(124.3867, 0) |
+-----------------------+
| 124 |
+-----------------------+
mysql> select truncate(-124.3867, -2);
+-------------------------+
| truncate(-124.3867, -2) |
+-------------------------+
| -100 |
+-------------------------+
```
### keywords
TRUNCATE

View File

@ -478,7 +478,34 @@
"label": "Math Functions",
"items": [
"sql-manual/sql-functions/math-functions/conv",
"sql-manual/sql-functions/math-functions/pmod"
"sql-manual/sql-functions/math-functions/pmod",
"sql-manual/sql-functions/math-functions/abs",
"sql-manual/sql-functions/math-functions/acos",
"sql-manual/sql-functions/math-functions/asin",
"sql-manual/sql-functions/math-functions/atan",
"sql-manual/sql-functions/math-functions/bin",
"sql-manual/sql-functions/math-functions/ceil",
"sql-manual/sql-functions/math-functions/cos",
"sql-manual/sql-functions/math-functions/degrees",
"sql-manual/sql-functions/math-functions/e",
"sql-manual/sql-functions/math-functions/exp",
"sql-manual/sql-functions/math-functions/greatest",
"sql-manual/sql-functions/math-functions/least",
"sql-manual/sql-functions/math-functions/ln",
"sql-manual/sql-functions/math-functions/log",
"sql-manual/sql-functions/math-functions/log10",
"sql-manual/sql-functions/math-functions/log2",
"sql-manual/sql-functions/math-functions/negative",
"sql-manual/sql-functions/math-functions/pi",
"sql-manual/sql-functions/math-functions/positive",
"sql-manual/sql-functions/math-functions/pow",
"sql-manual/sql-functions/math-functions/radians",
"sql-manual/sql-functions/math-functions/round",
"sql-manual/sql-functions/math-functions/sign",
"sql-manual/sql-functions/math-functions/sin",
"sql-manual/sql-functions/math-functions/sqrt",
"sql-manual/sql-functions/math-functions/tan",
"sql-manual/sql-functions/math-functions/truncate"
]
},
{

View File

@ -0,0 +1,62 @@
---
{
"title": "abs",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## abs
### description
#### Syntax
`DOUBLE abs(DOUBLE x)` `SMALLINT abs(TINYINT x)` `INT abs(SMALLINT x)`
`BIGINT abs(INT x)` `LARGEINT abs(BIGINT x)` `LARGEINT abs(LARGEINT x)`
`DOUBLE abs(DOUBLE x)` `FLOAT abs(FLOAT x)` `DECIMAL abs(DECIMAL x)`
返回`x`的绝对值.
### example
```
mysql> select abs(-2);
+---------+
| abs(-2) |
+---------+
| 2 |
+---------+
mysql> select abs(3.254655654);
+------------------+
| abs(3.254655654) |
+------------------+
| 3.254655654 |
+------------------+
mysql> select abs(-3254654236547654354654767);
+---------------------------------+
| abs(-3254654236547654354654767) |
+---------------------------------+
| 3254654236547654354654767 |
+---------------------------------+
```
### keywords
ABS

View File

@ -0,0 +1,57 @@
---
{
"title": "acos",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## acos
### description
#### Syntax
`DOUBLE acos(DOUBLE x)`
返回`x`的反余弦值,若 `x`不在`-1``1`的范围之内,则返回 `nan`.
### example
```
mysql> select acos(1);
+-----------+
| acos(1.0) |
+-----------+
| 0 |
+-----------+
mysql> select acos(0);
+--------------------+
| acos(0.0) |
+--------------------+
| 1.5707963267948966 |
+--------------------+
mysql> select acos(-2);
+------------+
| acos(-2.0) |
+------------+
| nan |
+------------+
```
### keywords
ACOS

View File

@ -0,0 +1,51 @@
---
{
"title": "asin",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## asin
### description
#### Syntax
`DOUBLE asin(DOUBLE x)`
返回`x`的反正弦值,若 `x`不在`-1``1`的范围之内,则返回 `nan`.
### example
```
mysql> select asin(0.5);
+---------------------+
| asin(0.5) |
+---------------------+
| 0.52359877559829893 |
+---------------------+
mysql> select asin(2);
+-----------+
| asin(2.0) |
+-----------+
| nan |
+-----------+
```
### keywords
ASIN

View File

@ -0,0 +1,51 @@
---
{
"title": "atan",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## atan
### description
#### Syntax
`DOUBLE atan(DOUBLE x)`
返回`x`的反正切值,`x`为弧度值.
### example
```
mysql> select atan(0);
+-----------+
| atan(0.0) |
+-----------+
| 0 |
+-----------+
mysql> select atan(2);
+--------------------+
| atan(2.0) |
+--------------------+
| 1.1071487177940904 |
+--------------------+
```
### keywords
ATAN

View File

@ -0,0 +1,57 @@
---
{
"title": "bin",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## bin
### description
#### Syntax
`STRING bin(BIGINT x)`
将十进制数`x`转换为二进制数.
### example
```
mysql> select bin(0);
+--------+
| bin(0) |
+--------+
| 0 |
+--------+
mysql> select bin(10);
+---------+
| bin(10) |
+---------+
| 1010 |
+---------+
mysql> select bin(-3);
+------------------------------------------------------------------+
| bin(-3) |
+------------------------------------------------------------------+
| 1111111111111111111111111111111111111111111111111111111111111101 |
+------------------------------------------------------------------+
```
### keywords
BIN

View File

@ -0,0 +1,57 @@
---
{
"title": "ceil",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## ceil
### description
#### Syntax
`BIGINT ceil(DOUBLE x)`
返回大于或等于`x`的最小整数值.
### example
```
mysql> select ceil(1);
+-----------+
| ceil(1.0) |
+-----------+
| 1 |
+-----------+
mysql> select ceil(2.4);
+-----------+
| ceil(2.4) |
+-----------+
| 3 |
+-----------+
mysql> select ceil(-10.3);
+-------------+
| ceil(-10.3) |
+-------------+
| -10 |
+-------------+
```
### keywords
CEIL

View File

@ -0,0 +1,57 @@
---
{
"title": "cos",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## cos
### description
#### Syntax
`DOUBLE cos(DOUBLE x)`
返回`x`的余弦值,`x` 为弧度值.
### example
```
mysql> select cos(1);
+---------------------+
| cos(1.0) |
+---------------------+
| 0.54030230586813977 |
+---------------------+
mysql> select cos(0);
+----------+
| cos(0.0) |
+----------+
| 1 |
+----------+
mysql> select cos(Pi());
+-----------+
| cos(pi()) |
+-----------+
| -1 |
+-----------+
```
### keywords
COS

View File

@ -0,0 +1,57 @@
---
{
"title": "degrees",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## degrees
### description
#### Syntax
`DOUBLE degrees(DOUBLE x)`
返回`x`的度, 从弧度转换为度.
### example
```
mysql> select degrees(0);
+--------------+
| degrees(0.0) |
+--------------+
| 0 |
+--------------+
mysql> select degrees(2);
+--------------------+
| degrees(2.0) |
+--------------------+
| 114.59155902616465 |
+--------------------+
mysql> select degrees(Pi());
+---------------+
| degrees(pi()) |
+---------------+
| 180 |
+---------------+
```
### keywords
DEGREES

View File

@ -0,0 +1,45 @@
---
{
"title": "e",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## e
### description
#### Syntax
`DOUBLE e()`
返回常量`e`值.
### example
```
mysql> select e();
+--------------------+
| e() |
+--------------------+
| 2.7182818284590451 |
+--------------------+
```
### keywords
E

View File

@ -0,0 +1,51 @@
---
{
"title": "exp",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## exp
### description
#### Syntax
`DOUBLE exp(DOUBLE x)`
返回以`e`为底的`x`的幂.
### example
```
mysql> select exp(2);
+------------------+
| exp(2.0) |
+------------------+
| 7.38905609893065 |
+------------------+
mysql> select exp(3.4);
+--------------------+
| exp(3.4) |
+--------------------+
| 29.964100047397011 |
+--------------------+
```
### keywords
EXP

View File

@ -0,0 +1,57 @@
---
{
"title": "floor",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## floor
### description
#### Syntax
`BIGINT floor(DOUBLE x)`
返回小于或等于`x`的最大整数值.
### example
```
mysql> select floor(1);
+------------+
| floor(1.0) |
+------------+
| 1 |
+------------+
mysql> select floor(2.4);
+------------+
| floor(2.4) |
+------------+
| 2 |
+------------+
mysql> select floor(-10.3);
+--------------+
| floor(-10.3) |
+--------------+
| -11 |
+--------------+
```
### keywords
FLOOR

View File

@ -0,0 +1,66 @@
---
{
"title": "greatest",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## greatest
### description
#### Syntax
`greatest(col_a, col_b, …, col_n)`
`column`支持以下类型:`TINYINT` `SMALLINT` `INT` `BIGINT` `LARGEINT` `FLOAT` `DOUBLE` `STRING` `DATETIME` `DECIMAL`
比较`n``column`的大小返回其中的最大值.若`column`中有`NULL`,则返回`NULL`.
### example
```
mysql> select greatest(-1, 0, 5, 8);
+-----------------------+
| greatest(-1, 0, 5, 8) |
+-----------------------+
| 8 |
+-----------------------+
mysql> select greatest(-1, 0, 5, NULL);
+--------------------------+
| greatest(-1, 0, 5, NULL) |
+--------------------------+
| NULL |
+--------------------------+
mysql> select greatest(6.3, 4.29, 7.6876);
+-----------------------------+
| greatest(6.3, 4.29, 7.6876) |
+-----------------------------+
| 7.6876 |
+-----------------------------+
mysql> select greatest("2022-02-26 20:02:11","2020-01-23 20:02:11","2020-06-22 20:02:11");
+-------------------------------------------------------------------------------+
| greatest('2022-02-26 20:02:11', '2020-01-23 20:02:11', '2020-06-22 20:02:11') |
+-------------------------------------------------------------------------------+
| 2022-02-26 20:02:11 |
+-------------------------------------------------------------------------------+
```
### keywords
GREATEST

View File

@ -0,0 +1,66 @@
---
{
"title": "least",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## least
### description
#### Syntax
`least(col_a, col_b, …, col_n)`
`column`支持以下类型:`TINYINT` `SMALLINT` `INT` `BIGINT` `LARGEINT` `FLOAT` `DOUBLE` `STRING` `DATETIME` `DECIMAL`
比较`n``column`的大小返回其中的最小值.若`column`中有`NULL`,则返回`NULL`.
### example
```
mysql> select least(-1, 0, 5, 8);
+--------------------+
| least(-1, 0, 5, 8) |
+--------------------+
| -1 |
+--------------------+
mysql> select least(-1, 0, 5, NULL);
+-----------------------+
| least(-1, 0, 5, NULL) |
+-----------------------+
| NULL |
+-----------------------+
mysql> select least(6.3, 4.29, 7.6876);
+--------------------------+
| least(6.3, 4.29, 7.6876) |
+--------------------------+
| 4.29 |
+--------------------------+
mysql> select least("2022-02-26 20:02:11","2020-01-23 20:02:11","2020-06-22 20:02:11");
+----------------------------------------------------------------------------+
| least('2022-02-26 20:02:11', '2020-01-23 20:02:11', '2020-06-22 20:02:11') |
+----------------------------------------------------------------------------+
| 2020-01-23 20:02:11 |
+----------------------------------------------------------------------------+
```
### keywords
LEAST

View File

@ -0,0 +1,57 @@
---
{
"title": "ln",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## ln
### description
#### Syntax
`DOUBLE ln(DOUBLE x)`
返回以`e`为底的`x`的自然对数.
### example
```
mysql> select ln(1);
+---------+
| ln(1.0) |
+---------+
| 0 |
+---------+
mysql> select ln(e());
+---------+
| ln(e()) |
+---------+
| 1 |
+---------+
mysql> select ln(10);
+--------------------+
| ln(10.0) |
+--------------------+
| 2.3025850929940459 |
+--------------------+
```
### keywords
LN

View File

@ -0,0 +1,57 @@
---
{
"title": "log",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## log
### description
#### Syntax
`DOUBLE log(DOUBLE b, DOUBLE x)`
返回基于底数`b``x`的对数.
### example
```
mysql> select log(5,1);
+---------------+
| log(5.0, 1.0) |
+---------------+
| 0 |
+---------------+
mysql> select log(3,20);
+--------------------+
| log(3.0, 20.0) |
+--------------------+
| 2.7268330278608417 |
+--------------------+
mysql> select log(2,65536);
+-------------------+
| log(2.0, 65536.0) |
+-------------------+
| 16 |
+-------------------+
```
### keywords
LOG

View File

@ -0,0 +1,57 @@
---
{
"title": "log10",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## log10
### description
#### Syntax
`DOUBLE log10(DOUBLE x)`
返回以`10`为底的`x`的自然对数.
### example
```
mysql> select log10(1);
+------------+
| log10(1.0) |
+------------+
| 0 |
+------------+
mysql> select log10(10);
+-------------+
| log10(10.0) |
+-------------+
| 1 |
+-------------+
mysql> select log10(16);
+--------------------+
| log10(16.0) |
+--------------------+
| 1.2041199826559248 |
+--------------------+
```
### keywords
LOG10

View File

@ -0,0 +1,57 @@
---
{
"title": "log2",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## log2
### description
#### Syntax
`DOUBLE log2(DOUBLE x)`
返回以`2`为底的`x`的自然对数.
### example
```
mysql> select log2(1);
+-----------+
| log2(1.0) |
+-----------+
| 0 |
+-----------+
mysql> select log2(2);
+-----------+
| log2(2.0) |
+-----------+
| 1 |
+-----------+
mysql> select log2(10);
+--------------------+
| log2(10.0) |
+--------------------+
| 3.3219280948873622 |
+--------------------+
```
### keywords
LOG2

View File

@ -0,0 +1,51 @@
---
{
"title": "negative",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## negative
### description
#### Syntax
`BIGINT negative(BIGINT x)` `DOUBLE negative(DOUBLE x)` `DECIMAL negative(DECIMAL x)`
返回`-x`.
### example
```
mysql> SELECT negative(-10);
+---------------+
| negative(-10) |
+---------------+
| 10 |
+---------------+
mysql> SELECT negative(12);
+--------------+
| negative(12) |
+--------------+
| -12 |
+--------------+
```
### keywords
NEGATIVE

View File

@ -0,0 +1,45 @@
---
{
"title": "Pi",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## Pi
### description
#### Syntax
`DOUBLE Pi()`
返回常量`Pi`值.
### example
```
mysql> select Pi();
+--------------------+
| pi() |
+--------------------+
| 3.1415926535897931 |
+--------------------+
```
### keywords
PI

View File

@ -0,0 +1,51 @@
---
{
"title": "positive",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## positive
### description
#### Syntax
`BIGINT positive(BIGINT x)` `DOUBLE positive(DOUBLE x)` `DECIMAL positive(DECIMAL x)`
返回`x`.
### example
```
mysql> SELECT positive(-10);
+---------------+
| positive(-10) |
+---------------+
| -10 |
+---------------+
mysql> SELECT positive(12);
+--------------+
| positive(12) |
+--------------+
| 12 |
+--------------+
```
### keywords
POSITIVE

View File

@ -0,0 +1,57 @@
---
{
"title": "pow",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## pow
### description
#### Syntax
`DOUBLE pow(DOUBLE a, DOUBLE b)`
返回`a``b`次方.
### example
```
mysql> select pow(2,0);
+---------------+
| pow(2.0, 0.0) |
+---------------+
| 1 |
+---------------+
mysql> select pow(2,3);
+---------------+
| pow(2.0, 3.0) |
+---------------+
| 8 |
+---------------+
mysql> select pow(3,2.4);
+--------------------+
| pow(3.0, 2.4) |
+--------------------+
| 13.966610165238235 |
+--------------------+
```
### keywords
POW

View File

@ -0,0 +1,57 @@
---
{
"title": "radians",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## radians
### description
#### Syntax
`DOUBLE radians(DOUBLE x)`
返回`x`的弧度值, 从度转换为弧度.
### example
```
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 |
+--------------------+
```
### keywords
RADIANS

View File

@ -0,0 +1,63 @@
---
{
"title": "round",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## round
### description
#### Syntax
`BIGINT round(DOUBLE x)`
`x`四舍五入后保留整数部分.
### example
```
mysql> select round(2.4);
+------------+
| round(2.4) |
+------------+
| 2 |
+------------+
mysql> select round(2.5);
+------------+
| round(2.5) |
+------------+
| 3 |
+------------+
mysql> select round(-3.4);
+-------------+
| round(-3.4) |
+-------------+
| -3 |
+-------------+
mysql> select round(-3.5);
+-------------+
| round(-3.5) |
+-------------+
| -4 |
+-------------+
```
### keywords
ROUND

View File

@ -0,0 +1,57 @@
---
{
"title": "sign",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## sign
### description
#### Syntax
`TINYINT sign(DOUBLE x)`
返回`x`的符号.负数,零或正数分别对应-1,0或1.
### example
```
mysql> select sign(3);
+-----------+
| sign(3.0) |
+-----------+
| 1 |
+-----------+
mysql> select sign(0);
+-----------+
| sign(0.0) |
+-----------+
| 0 |
mysql> select sign(-10.0);
+-------------+
| sign(-10.0) |
+-------------+
| -1 |
+-------------+
1 row in set (0.01 sec)
```
### keywords
SIGN

View File

@ -0,0 +1,57 @@
---
{
"title": "sin",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## sin
### description
#### Syntax
`DOUBLE sin(DOUBLE x)`
返回`x`的正弦值,`x` 为弧度值.
### example
```
mysql> select sin(0);
+----------+
| sin(0.0) |
+----------+
| 0 |
+----------+
mysql> select sin(1);
+--------------------+
| sin(1.0) |
+--------------------+
| 0.8414709848078965 |
+--------------------+
mysql> select sin(0.5 * Pi());
+-----------------+
| sin(0.5 * pi()) |
+-----------------+
| 1 |
+-----------------+
```
### keywords
SIN

View File

@ -0,0 +1,57 @@
---
{
"title": "sqrt",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## sqrt
### description
#### Syntax
`DOUBLE sqrt(DOUBLE x)`
返回`x`的平方根,要求x大于或等于0.
### example
```
mysql> select sqrt(9);
+-----------+
| sqrt(9.0) |
+-----------+
| 3 |
+-----------+
mysql> select sqrt(2);
+--------------------+
| sqrt(2.0) |
+--------------------+
| 1.4142135623730951 |
+--------------------+
mysql> select sqrt(100.0);
+-------------+
| sqrt(100.0) |
+-------------+
| 10 |
+-------------+
```
### keywords
SQRT

View File

@ -0,0 +1,51 @@
---
{
"title": "tan",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## tan
### description
#### Syntax
`DOUBLE tan(DOUBLE x)`
返回`x`的正切值,`x`为弧度值.
### example
```
mysql> select tan(0);
+----------+
| tan(0.0) |
+----------+
| 0 |
+----------+
mysql> select tan(1);
+--------------------+
| tan(1.0) |
+--------------------+
| 1.5574077246549023 |
+--------------------+
```
### keywords
TAN

View File

@ -0,0 +1,62 @@
---
{
"title": "truncate",
"language": "zh-CN"
}
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
## truncate
### description
#### Syntax
`DOUBLE truncate(DOUBLE x, INT d)`
按照保留小数的位数`d``x`进行数值截取。
规则如下:
`d > 0`时:保留`x``d`位小数
`d = 0`时:将`x`的小数部分去除,只保留整数部分
`d < 0`时:将`x`的小数部分去除,整数部分按照 `d`所指定的位数,采用数字`0`进行替换
### example
```
mysql> select truncate(124.3867, 2);
+-----------------------+
| truncate(124.3867, 2) |
+-----------------------+
| 124.38 |
+-----------------------+
mysql> select truncate(124.3867, 0);
+-----------------------+
| truncate(124.3867, 0) |
+-----------------------+
| 124 |
+-----------------------+
mysql> select truncate(-124.3867, -2);
+-------------------------+
| truncate(-124.3867, -2) |
+-------------------------+
| -100 |
+-------------------------+
```
### keywords
TRUNCATE