Updated on 2026-11-06 GMT+08:00

trunc_numeric

The trunc_numeric function is used to truncate the input number to the specified number of decimal places.

Syntax

trunc_numeric(<number>[, bigint<decimal_places>])

Parameters

Table 1 Parameter descriptions

Parameter

Mandatory

Type

Description

number

Yes

DOUBLE, BIGINT, DECIMAL, or STRING

The data to be truncated.

decimal_places

No

BIGINT

The default value is 0. Truncates to the Nth decimal place.

Return Values

Returns a value of type DOUBLE or DECIMAL.

Return rules are as follows:

  • When number is of type DOUBLE or DECIMAL, the corresponding type is returned.
  • When number is of type STRING or BIGINT, a DOUBLE type is returned.
  • If decimal_places is not of type BIGINT, an error is returned.
  • If the number value is NULL, NULL is returned.

Example Code

  • Example 1
    Returns 3.141.
    select trunc_numeric(3.1415926, 3);
  • Example 2
    Returns 3.
    select trunc_numeric(3.1415926);