Teradata Built-In Functions: TO_NUMBER, TRUNC, CEILING, FLOOR, LEAST, GREATEST, ROUND

TO_NUMBER

I have often needed a function to verify whether a character column contains a numeric value. Typically, I have resorted to using a workaround, such as:

CASE WHEN UPPER(‘12.77’) = LOWER(‘12.77’) THEN ‘IS_NUMERIC’ ELSE ‘IS_NOT_NUMERIC’ END

Naturally, this workaround is limited and cannot manage certain situations, such as consecutive special characters.

With the introduction of the TO_NUMBER function in Teradata 14.00, it became possible to verify whether a given string is numeric.

CASE WHEN TO_NUMBER(‘12.77’) IS NOT NULL THEN ‘IS_NUMERIC’ ELSE ‘IS_NOT_NUMERIC’ END

Although there has always been an IS_NUMERIC function that users could define, I frequently encounter issues at client sites where execution permissions for these functions are absent. This problem is not present with the built-in functions.

TRUNC

TRUNC will truncate a numeric value (such as decimal(n,m)):

Trunc all decimal places: SELECT TRUNC(12.67) 12.00

Trunc after the first 2 decimal places: SELECT TRUNC(12.1266,2) 12.1200

CEILING

The CEILING function outputs the minimum integer value greater than or equal to the given input.

SELECT CEILING(4.78)
5.00

FLOOR

This function is comparable to CEILING in operation but instead returns the maximum integer that is less than or equal to the provided input value.

SELECT FLOOR(4.78)
4.00

LEAST

The function LEAST retrieves the minimum value from a series of input values.

SELECT LEAST(12.50, 1.00, 2.88)
1.00

GREATEST

The GREATEST function retrieves the maximum value from a set of input values.

SELECT GREATEST(12.50, 1.00, 2.88)
12.50

ROUND

ROUND will round numerical values.

Round with zero decimal places
SELECT ROUND(12.12)
12.00

Round with two decimal places
SELECT ROUND(12.1266,2)
12.13

Related Services

⚡ Need Help Optimizing Your Data Platform?

We cut data platform costs by 30–60% without hardware changes. 25+ years of hands-on tuning experience.

Explore Our Services →

📋 Considering a Move From Teradata?

Get a personalized migration roadmap in 2 minutes. We have migrated billions of rows from Teradata to Snowflake, Databricks, and more.

Free Migration Assessment →

📊 Data Platform Migration Survey

Help us map where the industry is heading. Results are public — see what others chose.

1. What is your current data platform?

2. Where are you migrating to (or evaluating)?

Migrating FROM
Migrating TO

Thanks for voting! Share this with your network.

Follow me on LinkedIn for daily insights on data warehousing and platform migrations.

Stay Ahead in Data Warehousing

Get expert insights on Teradata, Snowflake, BigQuery, Databricks, Microsoft Fabric, and modern data architecture — delivered to your inbox.

Leave a Comment

DWHPro

Expert network for enterprise data platforms. Senior consultants, project teams built for your challenge — across Teradata, Snowflake, Databricks, and more.

📍Vienna, Austria & Jacksonville, Florida

Quick Links
Services Team Teradata Book Blog Contact Us
Connect
LinkedIn → [email protected]
Newsletter

Join 4,000+ data professionals.
Weekly insights on Teradata, Snowflake & data architecture.