Learn about numeric functions in MariaDB Server. This section details SQL functions for performing mathematical calculations, rounding, and manipulating numeric values in your queries.
ABS(X)
Returns the absolute (non-negative) value of X
. If X
is not a number, it is converted to a numeric type.
SELECT ABS(42);
+---------+
| ABS(42) |
+---------+
| 42 |
+---------+
SELECT ABS(-42);
+----------+
| ABS(-42) |
+----------+
| 42 |
+----------+
SELECT ABS(DATE '1994-01-01');
+------------------------+
| ABS(DATE '1994-01-01') |
+------------------------+
| 19940101 |
+------------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
ACOS(X)
Returns the arc cosine of X
, that is, the value whose cosine is X
. Returns NULL
if X
is not in the range -1
to 1
.
SELECT ACOS(1);
+---------+
| ACOS(1) |
+---------+
| 0 |
+---------+
SELECT ACOS(1.0001);
+--------------+
| ACOS(1.0001) |
+--------------+
| NULL |
+--------------+
SELECT ACOS(0);
+-----------------+
| ACOS(0) |
+-----------------+
| 1.5707963267949 |
+-----------------+
SELECT ACOS(0.234);
+------------------+
| ACOS(0.234) |
+------------------+
| 1.33460644244679 |
+------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
+
Addition.
If both operands are integers, the result is calculated with BIGINT precision. If either integer is unsigned, the result is also an unsigned integer.
For real or string operands, the operand with the highest precision determines the result precision.
SELECT 3+5;
+-----+
| 3+5 |
+-----+
| 8 |
+-----+
This page is licensed: GPLv2, originally from fill_help_tables.sql
ASIN(X)
Returns the arc sine of X, that is, the value whose sine is X. Returns NULL
if X is not in the range -1 to 1.
SELECT ASIN(0.2);
+--------------------+
| ASIN(0.2) |
+--------------------+
| 0.2013579207903308 |
+--------------------+
SELECT ASIN('foo');
+-------------+
| ASIN('foo') |
+-------------+
| 0 |
+-------------+
SHOW WARNINGS;
+---------+------+-----------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'foo' |
+---------+------+-----------------------------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
ATAN(X)
Returns the arc tangent of X, that is, the value whose tangent is X.
SELECT ATAN(2);
+--------------------+
| ATAN(2) |
+--------------------+
| 1.1071487177940904 |
+--------------------+
SELECT ATAN(-2);
+---------------------+
| ATAN(-2) |
+---------------------+
| -1.1071487177940904 |
+---------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
ATAN(Y,X), ATAN2(Y,X)
Returns the arc tangent of the two variables X and Y. It is similar to calculating the arc tangent of Y / X, except that the signs of both arguments are used to determine the quadrant of the result.
SELECT ATAN(-2,2);
+---------------------+
| ATAN(-2,2) |
+---------------------+
| -0.7853981633974483 |
+---------------------+
SELECT ATAN2(PI(),0);
+--------------------+
| ATAN2(PI(),0) |
+--------------------+
| 1.5707963267948966 |
+--------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
CEIL(X)
CEIL()
is a synonym for CEILING().
This page is licensed: GPLv2, originally from fill_help_tables.sql
CEILING(X)
Returns the smallest integer value not less than X.
SELECT CEILING(1.23);
+---------------+
| CEILING(1.23) |
+---------------+
| 2 |
+---------------+
SELECT CEILING(-1.23);
+----------------+
| CEILING(-1.23) |
+----------------+
| -1 |
+----------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
CONV(N,from_base,to_base)
Converts numbers between different number bases. Returns a string representation of the number N
, converted from base from_base
to base to_base
.
Returns NULL
if any argument is NULL
, or if the second or third argument are not in the allowed range.
The argument N
is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 62. If to_base
is a negative number, N
is regarded as a signed number. Otherwise, N
is treated as unsigned. CONV()
works with 64-bit precision.
The argument N
is interpreted as an integer, but may be specified as an integer or a string. The minimum base is 2 and the maximum base is 36. If to_base
is a negative number, N
is regarded as a signed number. Otherwise, N
is treated as unsigned. CONV()
works with 64-bit precision.
Some shortcuts for this function are also available: BIN(), OCT(), HEX(), UNHEX(). Also, MariaDB allows binary literal values and hexadecimal literal values.
SELECT CONV('a',16,2);
+----------------+
| CONV('a',16,2) |
+----------------+
| 1010 |
+----------------+
SELECT CONV('6E',18,8);
+-----------------+
| CONV('6E',18,8) |
+-----------------+
| 172 |
+-----------------+
SELECT CONV(-17,10,-18);
+------------------+
| CONV(-17,10,-18) |
+------------------+
| -H |
+------------------+
SELECT CONV(12+'10'+'10'+0xa,10,10);
+------------------------------+
| CONV(12+'10'+'10'+0xa,10,10) |
+------------------------------+
| 42 |
+------------------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
COS(X)
Returns the cosine of X, where X is given in radians.
SELECT COS(PI());
+-----------+
| COS(PI()) |
+-----------+
| -1 |
+-----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
COT(X)
Returns the cotangent of X.
SELECT COT(42);
+--------------------+
| COT(42) |
+--------------------+
| 0.4364167060752729 |
+--------------------+
SELECT COT(12);
+---------------------+
| COT(12) |
+---------------------+
| -1.5726734063976893 |
+---------------------+
SELECT COT(0);
ERROR 1690 (22003): DOUBLE value is out of range in 'cot(0)'
This page is licensed: GPLv2, originally from fill_help_tables.sql
CRC32([par,]expr)
CRC32(expr)
Computes a cyclic redundancy check (CRC) value and returns a 32-bit unsigned value. The result is NULL
if the argument is NULL
. The argument is expected to be a string and (if possible) is treated as one if it is not.
Uses the alternate Castagnoli polynomia.
Often, CRC is computed in pieces. To facilitate this, there's an optional parameter: CRC32('MariaDB')=CRC32(CRC32('Maria'),'DB').
Uses the ISO 3309 polynomial that used by zlib and many others.
SELECT CRC32(CRC32('Maria'),'DB');
+----------------------------+
| CRC32(CRC32('Maria'),'DB') |
+----------------------------+
| 4227209140 |
+----------------------------+
SELECT CRC32('MariaDB');
+------------------+
| CRC32('MariaDB') |
+------------------+
| 4227209140 |
+------------------+
SELECT CRC32('mariadb');
+------------------+
| CRC32('mariadb') |
+------------------+
| 2594253378 |
+------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
CRC32C
is used to compute a cyclic redundancy check (CRC) value using the Castagnoli polynomial.
CRC32C([par,]expr)
MariaDB has always included a native unary function CRC32() that computes the CRC-32 of a string using the ISO 3309 polynomial that used by zlib and many others.
InnoDB and MyRocks use a different polynomial, which was implemented in SSE4.2 instructions that were introduced in the Intel Nehalem microarchitecture. This is commonly called CRC-32C (Castagnoli).
The CRC32C function uses the Castagnoli polynomial.
This allows SELECT…INTO DUMPFILE
to be used for the creation of files with valid checksums, such as a logically empty InnoDB redo log fileib_logfile0
corresponding to a particular log sequence number.
The optional parameter allows the checksum to be computed in pieces: CRC32C('MariaDB')=CRC32C(CRC32C('Maria'),'DB').
SELECT CRC32C('MariaDB');
+-------------------+
| CRC32C('MariaDB') |
+-------------------+
| 809606978 |
+-------------------+
SELECT CRC32C(CRC32C('Maria'),'DB');
+------------------------------+
| CRC32C(CRC32C('Maria'),'DB') |
+------------------------------+
| 809606978 |
+------------------------------+
This page is licensed: CC BY-SA / Gnu FDL
DEGREES(X)
Returns the argument X
, converted from radians to degrees.
This is the converse of the RADIANS() function.
SELECT DEGREES(PI());
+---------------+
| DEGREES(PI()) |
+---------------+
| 180 |
+---------------+
SELECT DEGREES(PI() / 2);
+-------------------+
| DEGREES(PI() / 2) |
+-------------------+
| 90 |
+-------------------+
SELECT DEGREES(45);
+-----------------+
| DEGREES(45) |
+-----------------+
| 2578.3100780887 |
+-----------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
DIV
Integer division. Similar to FLOOR(), but is safe with BIGINT values. Incorrect results may occur for non-integer operands that exceed the BIGINT
range.
If the ERROR_ON_DIVISION_BY_ZERO
SQL_MODE is used, a division by zero produces an error. Otherwise, it returns NULL
.
The remainder of a division can be obtained using the MOD operator.
SELECT 300 DIV 7;
+-----------+
| 300 DIV 7 |
+-----------+
| 42 |
+-----------+
SELECT 300 DIV 0;
+-----------+
| 300 DIV 0 |
+-----------+
| NULL |
+-----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
/
Division operator. Dividing by zero will return NULL
. By default, returns four digits after the decimal. This is determined by the server system variable div_precision_increment which by default is four. It can be set from 0 to 30.
Dividing by zero returns NULL
. If the default ERROR_ON_DIVISION_BY_ZERO
SQL_MODE is used, a division by zero also produces a warning.
SELECT 4/5;
+--------+
| 4/5 |
+--------+
| 0.8000 |
+--------+
SELECT 300/(2-2);
+-----------+
| 300/(2-2) |
+-----------+
| NULL |
+-----------+
SELECT 300/7;
+---------+
| 300/7 |
+---------+
| 42.8571 |
+---------+
Changing div_precision_increment for the session from the default of four to six:
SET div_precision_increment = 6;
SELECT 300/7;
+-----------+
| 300/7 |
+-----------+
| 42.857143 |
+-----------+
SELECT 300/7;
+-----------+
| 300/7 |
+-----------+
| 42.857143 |
+-----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
EXP(X)
Returns the value of e (the base of natural logarithms) raised to the power of X. The inverse of this function is LOG() (using a single argument only) or LN().
If X
is NULL
, this function returns NULL
.
SELECT EXP(2);
+------------------+
| EXP(2) |
+------------------+
| 7.38905609893065 |
+------------------+
SELECT EXP(-2);
+--------------------+
| EXP(-2) |
+--------------------+
| 0.1353352832366127 |
+--------------------+
SELECT EXP(0);
+--------+
| EXP(0) |
+--------+
| 1 |
+--------+
SELECT EXP(NULL);
+-----------+
| EXP(NULL) |
+-----------+
| NULL |
+-----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
FLOOR(X)
Returns the largest integer value not greater than X.
SELECT FLOOR(1.23);
+-------------+
| FLOOR(1.23) |
+-------------+
| 1 |
+-------------+
SELECT FLOOR(-1.23);
+--------------+
| FLOOR(-1.23) |
+--------------+
| -2 |
+--------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
LN(X)
Returns the natural logarithm of X; that is, the base-e logarithm of X. If X is less than or equal to 0, or NULL
, then NULL
is returned.
The inverse of this function is EXP().
SELECT LN(2);
+-------------------+
| LN(2) |
+-------------------+
| 0.693147180559945 |
+-------------------+
SELECT LN(-2);
+--------+
| LN(-2) |
+--------+
| NULL |
+--------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
LOG(X), LOG(B,X)
If called with one parameter, this function returns the natural logarithm of X. If X is less than or equal to 0, then NULL
is returned.
If called with two parameters, it returns the logarithm of X to the base B. If B is <= 1 or X <= 0, the function returns NULL
.
If any argument is NULL
, the function returns NULL
.
The inverse of this function (when called with a single argument) is the EXP() function.
LOG(X):
SELECT LOG(2);
+-------------------+
| LOG(2) |
+-------------------+
| 0.693147180559945 |
+-------------------+
SELECT LOG(-2);
+---------+
| LOG(-2) |
+---------+
| NULL |
+---------+
LOG(B,X)
SELECT LOG(2,16);
+-----------+
| LOG(2,16) |
+-----------+
| 4 |
+-----------+
SELECT LOG(3,27);
+-----------+
| LOG(3,27) |
+-----------+
| 3 |
+-----------+
SELECT LOG(3,1);
+----------+
| LOG(3,1) |
+----------+
| 0 |
+----------+
SELECT LOG(3,0);
+----------+
| LOG(3,0) |
+----------+
| NULL |
+----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
LOG10(X)
Returns the base-10 logarithm of X.
SELECT LOG10(2);
+-------------------+
| LOG10(2) |
+-------------------+
| 0.301029995663981 |
+-------------------+
SELECT LOG10(100);
+------------+
| LOG10(100) |
+------------+
| 2 |
+------------+
SELECT LOG10(-100);
+-------------+
| LOG10(-100) |
+-------------+
| NULL |
+-------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
LOG2(X)
Returns the base-2 logarithm of X.
SELECT LOG2(4398046511104);
+---------------------+
| LOG2(4398046511104) |
+---------------------+
| 42 |
+---------------------+
SELECT LOG2(65536);
+-------------+
| LOG2(65536) |
+-------------+
| 16 |
+-------------+
SELECT LOG2(-100);
+------------+
| LOG2(-100) |
+------------+
| NULL |
+------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
MOD(N,M), N % M, N MOD M
Modulo operation. Returns the remainder of N divided by M. See also Modulo Operator.
If the ERROR_ON_DIVISION_BY_ZERO
SQL_MODE is used, any number modulus zero produces an error. Otherwise, it returns NULL
.
The integer part of a division can be obtained using DIV.
SELECT 1042 % 50;
+-----------+
| 1042 % 50 |
+-----------+
| 42 |
+-----------+
SELECT MOD(234, 10);
+--------------+
| MOD(234, 10) |
+--------------+
| 4 |
+--------------+
SELECT 253 % 7;
+---------+
| 253 % 7 |
+---------+
| 1 |
+---------+
SELECT MOD(29,9);
+-----------+
| MOD(29,9) |
+-----------+
| 2 |
+-----------+
SELECT 29 MOD 9;
+----------+
| 29 MOD 9 |
+----------+
| 2 |
+----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
*
Multiplication operator.
SELECT 7*6;
+-----+
| 7*6 |
+-----+
| 42 |
+-----+
SELECT 1234567890*9876543210;
+-----------------------+
| 1234567890*9876543210 |
+-----------------------+
| -6253480962446024716 |
+-----------------------+
SELECT 18014398509481984*18014398509481984.0;
+---------------------------------------+
| 18014398509481984*18014398509481984.0 |
+---------------------------------------+
| 324518553658426726783156020576256.0 |
+---------------------------------------+
SELECT 18014398509481984*18014398509481984;
+-------------------------------------+
| 18014398509481984*18014398509481984 |
+-------------------------------------+
| 0 |
+-------------------------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
OCT(N)
Returns a string representation of the octal value of N, where N is a longlong (BIGINT) number. This is equivalent to CONV(N,10,8). Returns NULL
if N is NULL
.
SELECT OCT(34);
+---------+
| OCT(34) |
+---------+
| 42 |
+---------+
SELECT OCT(12);
+---------+
| OCT(12) |
+---------+
| 14 |
+---------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
PI()
Returns the value of π (pi). The default number of decimal places displayed is six, but MariaDB uses the full double-precision value internally.
SELECT PI();
+----------+
| PI() |
+----------+
| 3.141593 |
+----------+
SELECT PI()+0.0000000000000000000000;
+-------------------------------+
| PI()+0.0000000000000000000000 |
+-------------------------------+
| 3.1415926535897931159980 |
+-------------------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
POW(X,Y)
Returns the value of X raised to the power of Y.
POWER()
is a synonym.
SELECT POW(2,3);
+----------+
| POW(2,3) |
+----------+
| 8 |
+----------+
SELECT POW(2,-2);
+-----------+
| POW(2,-2) |
+-----------+
| 0.25 |
+-----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
POWER(X,Y)
This is a synonym for POW(), which returns the value of X raised to the power of Y.
This page is licensed: GPLv2, originally from fill_help_tables.sql
RADIANS(X)
Returns the argument X
, converted from degrees to radians. Note that π radians equals 180 degrees.
This is the converse of the DEGREES() function.
SELECT RADIANS(45);
+-------------------+
| RADIANS(45) |
+-------------------+
| 0.785398163397448 |
+-------------------+
SELECT RADIANS(90);
+-----------------+
| RADIANS(90) |
+-----------------+
| 1.5707963267949 |
+-----------------+
SELECT RADIANS(PI());
+--------------------+
| RADIANS(PI()) |
+--------------------+
| 0.0548311355616075 |
+--------------------+
SELECT RADIANS(180);
+------------------+
| RADIANS(180) |
+------------------+
| 3.14159265358979 |
+------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
RAND(), RAND(N)
Returns a random DOUBLE precision floating point value v in the range 0 <= v < 1.0. If a constant integer argument N is specified, it is used as the seed value, which produces a repeatable sequence of column values. In the example below, note that the sequences of values produced by RAND(3)
is the same both places where it occurs.
In a WHERE
clause, RAND()
is evaluated each time the WHERE
is executed.
Statements using the RAND()
function are not safe for statement-based replication.
The expression to get a random integer from a given range is the following:
FLOOR(min_value + RAND() * (max_value - min_value +1))
RAND()
is often used to read random rows from a table, as follows:
SELECT * FROM my_table ORDER BY RAND() LIMIT 10;
Note, however, that this technique should never be used on a large table as it will be extremely slow. MariaDB will read all rows in the table, generate a random value for each of them, order them, and finally will apply the LIMIT
clause.
CREATE TABLE t (i INT);
INSERT INTO t VALUES(1),(2),(3);
SELECT i, RAND() FROM t;
+------+-------------------+
| i | RAND() |
+------+-------------------+
| 1 | 0.255651095188829 |
| 2 | 0.833920199269355 |
| 3 | 0.40264774151393 |
+------+-------------------+
SELECT i, RAND(3) FROM t;
+------+-------------------+
| i | RAND(3) |
+------+-------------------+
| 1 | 0.90576975597606 |
| 2 | 0.373079058130345 |
| 3 | 0.148086053457191 |
+------+-------------------+
SELECT i, RAND() FROM t;
+------+-------------------+
| i | RAND() |
+------+-------------------+
| 1 | 0.511478140495232 |
| 2 | 0.349447508668012 |
| 3 | 0.212803152588013 |
+------+-------------------+
Using the same seed, the same sequence will be returned:
SELECT i, RAND(3) FROM t;
+------+-------------------+
| i | RAND(3) |
+------+-------------------+
| 1 | 0.90576975597606 |
| 2 | 0.373079058130345 |
| 3 | 0.148086053457191 |
+------+-------------------+
Generating a random number from 5 to 15:
SELECT FLOOR(5 + (RAND() * 11));
This page is licensed: GPLv2, originally from fill_help_tables.sql
ROUND(X), ROUND(X,D)
Rounds the argument X
to D
decimal places. D
defaults to 0
if not specified.D
can be negative to cause D
digits left of the decimal point of the value X
to become zero.
The rounding algorithm depends on the data type of X
:
For fixed-point types (DECIMAL, DEC/NUMBER/FIXED) the "round half up" rule is used, meaning that e.g. a value ending in exactly .5 is always rounded up.
SELECT ROUND(-1.23);
+--------------+
| ROUND(-1.23) |
+--------------+
| -1 |
+--------------+
SELECT ROUND(-1.58);
+--------------+
| ROUND(-1.58) |
+--------------+
| -2 |
+--------------+
SELECT ROUND(1.58);
+-------------+
| ROUND(1.58) |
+-------------+
| 2 |
+-------------+
SELECT ROUND(1.298, 1);
+-----------------+
| ROUND(1.298, 1) |
+-----------------+
| 1.3 |
+-----------------+
SELECT ROUND(1.298, 0);
+-----------------+
| ROUND(1.298, 0) |
+-----------------+
| 1 |
+-----------------+
SELECT ROUND(23.298, -1);
+-------------------+
| ROUND(23.298, -1) |
+-------------------+
| 20 |
+-------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
SIGN(X)
Returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive.
SELECT SIGN(-32);
+-----------+
| SIGN(-32) |
+-----------+
| -1 |
+-----------+
SELECT SIGN(0);
+---------+
| SIGN(0) |
+---------+
| 0 |
+---------+
SELECT SIGN(234);
+-----------+
| SIGN(234) |
+-----------+
| 1 |
+-----------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
SIN(X)
Returns the sine of X, where X is given in radians.
SELECT SIN(1.5707963267948966);
+-------------------------+
| SIN(1.5707963267948966) |
+-------------------------+
| 1 |
+-------------------------+
SELECT SIN(PI());
+----------------------+
| SIN(PI()) |
+----------------------+
| 1.22460635382238e-16 |
+----------------------+
SELECT ROUND(SIN(PI()));
+------------------+
| ROUND(SIN(PI())) |
+------------------+
| 0 |
+------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
SQRT(X)
Returns the square root of X. If X is negative, NULL
is returned.
SELECT SQRT(4);
+---------+
| SQRT(4) |
+---------+
| 2 |
+---------+
SELECT SQRT(20);
+------------------+
| SQRT(20) |
+------------------+
| 4.47213595499958 |
+------------------+
SELECT SQRT(-16);
+-----------+
| SQRT(-16) |
+-----------+
| NULL |
+-----------+
SELECT SQRT(1764);
+------------+
| SQRT(1764) |
+------------+
| 42 |
+------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
TAN(X)
Returns the tangent of X, where X is given in radians.
SELECT TAN(0.7853981633974483);
+-------------------------+
| TAN(0.7853981633974483) |
+-------------------------+
| 0.9999999999999999 |
+-------------------------+
SELECT TAN(PI());
+-----------------------+
| TAN(PI()) |
+-----------------------+
| -1.22460635382238e-16 |
+-----------------------+
SELECT TAN(PI()+1);
+-----------------+
| TAN(PI()+1) |
+-----------------+
| 1.5574077246549 |
+-----------------+
SELECT TAN(RADIANS(PI()));
+--------------------+
| TAN(RADIANS(PI())) |
+--------------------+
| 0.0548861508080033 |
+--------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql
This page documents the TRUNCATE function. See TRUNCATE TABLE for the DDL statement.
TRUNCATE(X,D)
Returns the number X, truncated to D decimal places. If D is 0, the result has no decimal point or fractional part. D can be negative to cause D digits left of the decimal point of the value X to become zero.
SELECT TRUNCATE(1.223,1);
+-------------------+
| TRUNCATE(1.223,1) |
+-------------------+
| 1.2 |
+-------------------+
SELECT TRUNCATE(1.999,1);
+-------------------+
| TRUNCATE(1.999,1) |
+-------------------+
| 1.9 |
+-------------------+
SELECT TRUNCATE(1.999,0);
+-------------------+
| TRUNCATE(1.999,0) |
+-------------------+
| 1 |
+-------------------+
SELECT TRUNCATE(-1.999,1);
+--------------------+
| TRUNCATE(-1.999,1) |
+--------------------+
| -1.9 |
+--------------------+
SELECT TRUNCATE(122,-2);
+------------------+
| TRUNCATE(122,-2) |
+------------------+
| 100 |
+------------------+
SELECT TRUNCATE(10.28*100,0);
+-----------------------+
| TRUNCATE(10.28*100,0) |
+-----------------------+
| 1028 |
+-----------------------+
This page is licensed: GPLv2, originally from fill_help_tables.sql