The following table describes the mathematical functions that are supported by PolarDB-X.
PolarDB-X supports the following mathematical functions.
Function | Description | Example |
---|---|---|
ABS(x) | Returns the absolute value of the x argument. | Calculate the absolute value of -1.
Sample response:
|
ACOS(x) | Calculates the arccosine of the x argument. The unit of the x argument is in radians. |
|
ASIN(x) | Calculates the arcsine of the x argument. The unit of the x argument is in radians. |
|
ATAN(x) | Calculates the arctangent of the x argument. The unit of the x argument is in radians. |
|
ATAN2(n, m) | Calculates the arctangent of the angle between the ray to the point (n, m) and the positive x-axis. The unit of the angle is in radians. |
|
AVG(expression) | Returns the average value of an expression. The expression is a field. | Calculate the average value of the Price field in the Products table.
|
CEIL(x) | Returns the minimum integer that is not less than the x argument. |
Sample response:
|
CEILING(x) | Returns the minimum integer that is not less than the x argument. |
Sample response:
|
COS(x) | Calculates the cosine of the x argument. The unit of the x argument is in radians. |
|
COT(x) | Calculates the cotangent of the x argument. The unit of the x argument is in radians. |
|
COUNT(expression) | Returns the number of records in an expression. The expression is a field or an asterisk (*). | Query the number of records in the ProductID field in the Products table.
|
DEGREES(x) | Converts an angle x that is expressed in radians to degrees. |
Sample response:
|
n DIV m | Returns the integer portion of the quotient that is obtained by dividing operand n by operand m. | Query the integer portion of the quotient that is obtained by dividing 10 by 5.
Sample response:
|
EXP(x) | Calculates the value of e to the power of x. In the formula, e indicates Euler's number. | Calculate the value of e to the power of 3.
Sample response:
|
FLOOR(x) | Returns the maximum integer that is not greater than the x argument. | Query the maximum integer that is not greater than 1.5.
Sample response:
|
GREATEST(expr1, expr2, expr3, ...) | Returns the maximum value from a list of values. | Query the maximum number from a list of numbers.
Sample response:
Query the maximum string from a list of strings.
Sample response:
|
LEAST(expr1, expr2, expr3, ...) | Returns the minimum value from a list of values. | Query the minimum number from a list of numbers.
Sample response:
Query the minimum string from a list of strings.
Sample response:
|
LN | Calculates the natural logarithm of a number. The natural logarithm of a number is its logarithm to the base of the mathematical constant e. | Calculate the natural logarithm of 2.
Sample response:
|
LOG(x) or LOG(base, x) | Returns the natural logarithm of x or the logarithm of x to a specified base. The natural logarithm of a number is its logarithm to the base of the mathematical constant e. If the base argument is specified, the function returns the logarithm of x to the base argument. |
|
LOG10(x) | Calculates the decimal logarithm of x. |
Sample response:
|
LOG2(x) | Calculates the binary logarithm of x. | Calculate the binary logarithm of 6.
Sample response:
|
MAX(expression) | Returns the maximum value in an expression. | Query the maximum value in the Price field in the Products table.
|
MIN(expression) | Returns the minimum value in an expression. | Query the minimum value in the Price field in the Products table.
|
MOD(x,y) | Calculates the remainder that is obtained by dividing x by y. | Calculate the remainder that is obtained by dividing 5 by 2.
Sample response:
|
PI() | Returns the value of pi that is rounded to six decimal places. Sample response: 3.141593. |
Sample response:
|
POW(x,y) | Calculates the value of x to the power of y. | Calculate 2 to the power of 3.
Sample response:
|
POWER(x,y) | Calculates the value of x to the power of y. | Calculate 2 to the power of 3.
Sample response:
|
RADIANS(x) | Converts an angle x that is expressed in degrees to radians. | Convert 180° to a value in radians.
Sample response:
|
RAND() | Returns a random number from 0 to 1. |
Sample response:
|
ROUND(x) | Rounds the x argument to the nearest integer. |
Sample response:
|
SIGN(x) | Returns a number to indicate whether the x argument is 0, negative, or positive. The value -1 is returned if the x argument is negative. The value 0 is returned if the x argument is 0. The value 1 is returned if the x argument is positive. |
Sample response:
|
SIN(x) | Calculates the sine of the x argument. The unit of the x argument is in radians. |
Sample response:
|
SQRT(x) | Calculates the square root of the x argument. | Calculate the square root of 25.
Sample response:
|
SUM(expression) | Calculates the sum of the values in an expression. | Calculate the sum of the values in the Quantity field in the OrderDetails table.
|
TAN(x) | Calculates the tangent of the x argument. The unit of the x argument is in radians. |
Sample response:
|
TRUNCATE(x,y) | Truncates the argument x to y decimal places without rounding a decimal value. The ROUND(x) function rounds x to the nearest integer. |
Sample response:
|