Functions（1）
Tags: opengauss
Published: 2023-03-09 04:31:05

The common functions of openGauss are as follows:

**Mathematical Functions**
**·** abs(x)

Description: Absolute value

Return type: same as the input

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqjrluzthhlmlqoe0484.png)

**·** cbrt(dp)

Description: Cubic root

Return type: double precision

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uyny5chvi6cd892r90c1.png)

**·** ceil(x)

Description: Minimum integer greater than or equal to the parameter

Return type: integer

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5crbtxnbbd1mthmhy4cy.png)

**·** degrees(dp)

Description: Converts radians to angles.

Return type: double precision

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/he703z7qeu3adjx0qgxg.png)

**·** exp(x)

Description: Natural exponent

Return type: dp or numeric. If implicit type conversion is not considered, the return type is the same as the input type.

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38gpy4alsryylwpqpwu7.png)

**·** floor(x)

Description: Maximum integer not larger than the parameter

Return type: same as the input

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2gkmp1bgcv37avnjv1h.png)

**·** ln(x)

Description: Natural logarithm

Return type: dp or numeric. If implicit type conversion is not considered, the return type is the same as the input type.

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ixfljmb03mo73782otq.png)

**·** log(x)

Description: Logarithm with 10 as the base

Return type: same as the input

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vxomrf3ry9fa9jmgxxm2.png)

**·** log(b numeric, x numeric)

Description: Logarithm with b as the base

Return type: numeric

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7y8emqasgelcjjrog7m.png)

**·** mod(x,y)

Description: Remainder of x/y (model) If x equals to 0, 0 is returned.

Return type: same as the parameter type

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14204umsqqhekhiys28r.png)

**·** pi()

Description: π constant value

Return type: double precision

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3o5b3833nyqtjnh3nmu0.png)

**·** power(a double precision, b double precision)

Description: b power of a

Return type: double precision

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6a80x63cemplycwwob44.png)

**·** radians(dp)

Description: Converts angles to radians.

Return type: double precision

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ew5buecmd20hwuqiec2j.png)

**·** random()

Description: Random number between 0.0 and 1.0

Return type: double precision

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8n1kros6btmbm03trl4n.png)

**·** round(x)

Description: Integer closest to the input parameter

Return type: same as the input

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv252c9a8hl8p02aapbh.png)

**·** round(v numeric, s int)

Description: s digits are kept after the decimal point.

Return type: numeric

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fiqkh4m97pmqm6rqjvwl.png)

**·** sign(x)

Description: Returns symbols of this parameter.

Return type: –1 indicates minus. 0 indicates 0, and 1 indicates positive numbers.

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mwfyjzbhsfhy6is6901v.png)

**·** sqrt(x)

Description: Square root

Return type: dp or numeric. If implicit type conversion is not considered, the return type is the same as the input type.

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1h3j7nob6qpw6xh6pcwa.png)

**·** trunc(x)

Description: Truncates (the integral part).

Return type: same as the input

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nsmhvdhalei0wi5j0znd.png)

**·** trunc(v numeric, s int)

Description: Truncates a number with s digits after the decimal point.

Return type: numeric

Example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/37qwsaf4s900cwemg0eo.png)