I have table called DART_STG1 in Netezza Database. The table has a varchar column. I am trying to use the below SQL to convert the varchar into a number, but it always throws an error.

Code

SELECT DISTINCT TO_NUMBER(M12,'99G99') 
FROM   DART_STG1 
WHERE  M12 IS NOT NULL;

Throws an error:

ERROR [HY000] ERROR: Bad numeric input format

What does this error mean?

有帮助吗?

解决方案 2

The error:

ERROR [HY000] ERROR: Bad numeric input format 

Is caused because you feeding letters into TO_NUMBER. You are feeding it 99G99 which is not a number.

The program tries to tell you it's not a number by telling you that the numeric input format is bad, as the error very clearly says.

其他提示

The PDA (Netezza) Conversion functions page provide examples, and together with the Template patterns, you can choose the appropriate format.

However I'm getting the same error for my data set. I'm suspecting it's something about the formatting of the values in STORE_NUMBER is what Netezza doesn't like.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top