Skip to content Skip to sidebar Skip to footer

Teradata - Comparing Varchar To Decimal

I am very new to Teradata and SQL in general. I need to create a table by combining data from three tables. I was able to successfully join two of them. I am not able to write the

Solution 1:

There's some bad data in u.colm.

Depending on your Teradata release you can check it using

WHERE u.colm > ''AND TRYCAST(u.colm asdecimal(10,0)) ISNULL

or

WHERE u.colm >''AND TO_NUMBER(u.colm) ISNULL

You can also use those in the join-condition, e.g.

on t.cold = trycast(u.colm asdecimal(10,0))

Don't forget to add the precision of the decimal, as it defaults to (5,0).

Your WHERE_condition is strange, what's the datatype of s.cola? Seems it's a string with a date yyyy-mm-dd in it. Try

WHERE trycast(s.cola asdate) betweendate'2017-11-06'anddate'2017-11-10'

Finally the ORDER BY should be placed after WHERE.

Post a Comment for "Teradata - Comparing Varchar To Decimal"