We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


cast used with to_number operator giving unexpected output — Vertica Forum

cast used with to_number operator giving unexpected output

Hello,

 

We are using vertica version : 7.2.3-2

 

Following unexpected thing i am facing :

 

I am getting a varchar column which i am converting to integer and doing cast on top of that.

 

Below is the query which i tried:

 

tdaadmin=> select cast(to_number('0.325000') as decimal(19,2));
to_number
-----------
0.33

 

This is the result which i expected and it came perfect , rounding off the value.

 

Now comes the below case :

 

tdaadmin=> select cast(to_number('0.725000') as decimal(19,2));
to_number
-----------
0.72
(1 row)

 

tdaadmin=> select cast(to_number('1.525') as decimal(19,2));
to_number
-----------
1.52
(1 row)

 

STRANGE ... It is not rounding off for the above , its giving unexpected o/p

 

Please can any one help me on the same.

 

 

Thanks,
Suhrid Ghosh

 

 

 

Comments

  • It's the to_number that messing things up. have you tried using the column name as is? without the to_number conversion?

     

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file