TRUNCATE
Truncates the given input to a given number of decimal places.
Syntax
Arguments
X
X
Type: numeric
A numeric value.
N
N
Type: integer
Default: 0
The number of decimal places to keep. This can be negative to truncate N
digits left of the decimal point.
If omitted, the precision defaults to 0 and X
is rounded to the nearest integer.
Returns
Type: double
X
truncated to PRECISION
decimal places.
Examples
X | Precision | Output |
---|---|---|
2.365 | 2.0 | |
1.456249 | 3 | 1.456 |
42.01934 | 2 | 42.01 |
1.1 | 1.0 | |
-1.1 | -1.0 | |
-1.9 | -1.0 | |
0 | 0.0 | |
0.5 | 0.0 | |
12.333 | -1 | 10.0 |
12.333 | 0 | 12.0 |
12.333 | 1 | 12.3 |
Transformation job example
SQL
Query result
orderid | nettotal | trunc_nettotal |
---|---|---|
04xYsBwxOW | 550.05 | 550 |
cu7qwoPA8q | 1871.68 | 1871 |
dB91uTY7Vv | 1538.02 | 1538 |
Last updated