Round function in Teradata

General
Enthusiast

Round function in Teradata

Hi everyone,

I am using teradata version 14

          I found a strange behavoir in teradata by applying Round function.. Here is an example

select  ROUND(178.22/100,5)

it gives the result as 1.78 --  and in other databases like oracle it gives the result 1.7822 

can anyone explain me , why teradata is not rounding the value upto the 5 decimal point in this case

Moreover ,  how can i get the same result as in orcale do

Thanks and regards,

ahmad

4 REPLIES
Junior Supporter

Re: Round function in Teradata

Hi.

178.22 is a DECIMAL(5,2). You have truncation if you do 178.22/100=1.78.

If you want 'Oracle' ROUND(), you can do a simple CAST:

SELECT ROUND(CAST(172.22 AS NUMBER)/100,5);

HTH.

Cheers.

Carlos

Enthusiast

Re: Round function in Teradata

Thank you carlos, 

it works... but still confused about teradata behaviour, As if i do a query like select  ROUND(178.2222/100,5) it will give the result as  1.7822..

why is required to cast in number to get exact number of fraction..

anyhow, thanks a lot...

Junior Supporter

Re: Round function in Teradata

Hi.

Teradata types are different from Oracle types (except NUMBER, which is the same). Your problem is the type, not the function. Take a look at the docs regarding datatypes.

You'll get the same result without the ROUND() with:

SELECT 178.22000/100;

Cheers.

Carlos.

Enthusiast

Re: Round function in Teradata

hi

       yes, you right, Actually, i was parsing the query from client application, and it looks hard to change my parsing engine. 

anyhow, thanks a lot dear... it helps me a lot...

ahmad...