Function: Example of taking the entire function round and floor in MySQL:
round(123.456,2) ------------ 123.47ROUND ( numeric_expression , length [ , function ] )
The numeric_expression parameter is an expression of exact or approximate numeric data type (except for bit data type ). Length is the precision of numeric_expression to be rounded. The length must be tinyint, smallint, or int. When length is a positive number, numeric_expression is rounded to the specified decimal place. When length is a negative number, numeric_expression is rounded to the left of the decimal point specified by length. Function is the operation type to be executed. The function must be tinyint, smallint, or int. If the value of function or function is omitted is 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.
round(123.456, 0) ------- 123.000 SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45) --------- --------- ----------- 123 -124 123.0000 SELECT CEILING(123.45), CEILING(-123.45), CEILING(0.0)
The result set is as follows: --------- ----------------------- 124-123 0 ///////////////////////////////// /////////////////// // The TRUNC of ORACLE is all-encompassing, the TRUNC of DB2 is only used for numbers. But can be implemented like DATE. For example, DATE (a timestamp field) removes all the values after TIMESTAMP into a pure date, just as ORACLE's TRUNC (SYSDATE) removes the subsequent time.
SQL> select trunc(2345.6789,2) from dual;TRUNC(2345.6789,2)------------------ 2345.67/home/db2inst > db2 -v "select decimal(2345.6789,10,2) from sysibm.sysdummy1"select decimal(2345.6789,10,2) from sysibm.sysdummy11------------ 2345.67 1 record(s) selected.