TRUNC

Math Function

Description

The TRUNC function truncates numbers to the previous integer or decimal.

For more information, please refer to TRUNC function.

Grammar Syntax

TRUNC(number [ , integer ])

This function is fully supported by Snowflake.

Sample Source Patterns

Input Code:

IN -> Redshift_01.sql
CREATE TABLE test_trunc_function (
    col1 INT,
    col2 FLOAT
 );

INSERT INTO test_trunc_function
VALUES ('200','111.13'),
       ('20','111.133444'),
       ('2','111.1350');

SELECT TRUNC(col1, -1), TRUNC(col2, -1) FROM test_trunc_function;

Output Code:

OUT -> Redshift_01.sql
CREATE TABLE test_trunc_function (
    col1 INT,
    col2 FLOAT
 )
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "09/30/2024" }}';

INSERT INTO test_trunc_function
VALUES ('200','111.13'),
       ('20','111.133444'),
       ('2','111.1350');

SELECT TRUNC(col1, -1), TRUNC(col2, -1) FROM test_trunc_function;

There are no known issues.

Last updated