Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:35:27+00:00 2026-06-14T17:35:27+00:00

With the Teradata database, it is possible to load values of NaN, -Inf, and

  • 0

With the Teradata database, it is possible to load values of NaN, -Inf, and +Inf into FLOAT columns through Java. Unfortunately, once those values get into the tables, they make life difficult when writing SQL that needs to filter them out. There is no IsNaN() function, nor can you “CAST (‘NaN’ as FLOAT)” and use an equality comparison.

What I would like to do is,

SELECT
  SUM(VAL**2)
FROM
  DTM
WHERE
  NOT ABS(VAL) > 1e+21 AND
  NOT VAL = CAST ('NaN' AS FLOAT)

but that fails with error 2620, “The format or data contains a bad character.”, specifically on the CAST. I’ve tried simply “… AND NOT VAL = ‘NaN'”, which also fails for a similar reason (3535, “A character string failed conversion to a numeric value.”). I cannot seem to figure out how to represent NaN within the SQL statement. Even if I could represent NaN successfully in an SQL statement, I would be concerned that the comparison would fail. According to the IEEE 754 spec, NaN = NaN should evaluate to false. What I really seem to need is an IsNaN() function. Yet that function does not seem to exist.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:35:29+00:00Added an answer on June 14, 2026 at 5:35 pm

    I have figured out a work-around, and I’ll share that with those of you searching for a solution. But first, it’s obvious to me that Teradata’s handling of NaN floating point values is incomplete and any behavior I’ve stumbled into figuring out is likely unintentional and inconsistent across different versions. So I offer the following free advice, with no guarantees, promises, or liabilities of any kind. Caveat emptor.

    After drilling down into the data, I find that if I CAST the FLOAT value to a VARCHAR(50), the NaN values come out as a string of 22 asterisks (**********************). I can cast to a VARCHAR(1) instead, and the NaN comes out as a single asterisk (*). That comparison isn’t that bad.

    SELECT
      SUM(VAL**2)
    FROM
      DTM
    WHERE
      NOT CAST (VAL AS VARCHAR(1)) = '*' AND
      ABS(VAL) < 1.0e+21
    

    I’ll note two things.

    First, my original desire of “NOT ABS(VAL) > 1.0e+21” on my version of Teradata seems to get converted to “ABS(VAL) <= 1.0e+21” under the covers. This (sometimes) fails because of the equality potion of the comparison — error [2651], “Operation Error computing expression involving VAL.” I’m assuming that the conversion from “NOT >” to “<=” is happening, because “NOT ABS(VAL) >= 1.0e+21” works fine (but looks ugly). Using “ABS(VAL) < 1.0e+21” works just fine and captures the need.

    Second, while I can’t reproduce it consistently, I have examples in my history where “ABS(VAL) <= 1.0e+21” does effectively screen out NaN, some where it doesn’t, and some where it fails with [2651] (see above), yet the SQL and the data in the tables were identical. The only conclusion I can come to is that Teradata is inconsistent in how it evaluates the comparison when NaN is involved (or it thinks it might be). It’s possible that different amps are handling it differently, but I don’t know for sure. That said, the above two comparisons in the where clause consistently and effectively screen out the Inf and NaN values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm converting database from Teradata to SqlServer. I've noticed all tables and procedures are
We need to access a Teradata database via php application We don't have odbc
I have two tables in a teradata database that look like this accounts account_number
I need to insert the data from an excel sheet into a teradata table.
I am just now starting to dig into Teradata's locking features and Google is
IS it possible to copy status message in teradata? (I don't want to type
This is on Teradata specifically, but in general, is it possible for a macro
I am designing a table in Teradata with about 30 columns. These columns are
I am trying to generate the below query in Teradata SQL Assistant. Unfortunately I
In Teradata, I need a query to first identify all members in the MEM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.