Decimal and zeroes removal

Database
N/A

Decimal and zeroes removal

Hi all,

I need to change this simple Teradate query but being new to this world not able to figure out why is it giving me error?

Some body please help.

I want my column as 20 instead of 20.00

TRANS_CNT as  CAST(TRANS_CNT AS DECIMAL(18,2) 

Thanks all

4 REPLIES
N/A

Re: Decimal and zeroes removal

TRANS_CNT as  CAST(TRANS_CNT AS DECIMAL(18,2) 

should be

TRANS_CNT as  CAST(TRANS_CNT AS DECIMAL(18,0) 

the 2 in your example defines the number of decimals

what did you have in mind as max-value of trans_cnt ?

in most cases an INTEGER will do the job

N/A

Re: Decimal and zeroes removal

I had tried (18,0) earlier.

However, INTEGER works fine.

Many Thanks!

Re: Decimal and zeroes removal

Hi Nila,

The Above query will not result in error instead it will not give you the desired result without the zeros.

SEL CAST(TRANS_CNT as DECIMAL(18,0));

OR

SEL CAST(TRANS_CNT as INTEGER);

OR

SEL SUBSTR(CAST(TRANS_CNT as DECIMAL(18,2)),1, 21-2);

Thanks & Regards,

Adharssh.

N/A

Re: Decimal and zeroes removal

Thank You!

I appriciate your detailed answer and option3 works best.