Is there an INT funtion in vertica?

Moderator: NorbertKrupa

Post Reply
User avatar
usli06
Intermediate
Intermediate
Posts: 93
Joined: Wed Jan 25, 2012 4:53 am

Is there an INT funtion in vertica?

Post by usli06 » Sat Jun 13, 2015 9:07 pm

Hi,

Is there a function in Vertica like the INT function in Oracle?

Example INT(4.56) would be 4.

Thanks!

NorbertKrupa
GURU
GURU
Posts: 527
Joined: Tue Oct 22, 2013 9:36 pm
Location: Chicago, IL
Contact:

Re: Is there an INT funtion in vertica?

Post by NorbertKrupa » Sun Jun 14, 2015 3:56 am

Are you just looking for the FLOOR function?

Code: Select all

dbadmin=> SELECT FLOOR('4.56');
 FLOOR
-------
     4
(1 row)
Checkout vertica.tips for more Vertica resources.

User avatar
usli06
Intermediate
Intermediate
Posts: 93
Joined: Wed Jan 25, 2012 4:53 am

Re: Is there an INT funtion in vertica?

Post by usli06 » Tue Jun 16, 2015 2:58 am

Yeah, thanks Norbert! For some reason I thought I tried that function and observed rounding issues, so I was using the TRUNC function, like this:

Code: Select all

dbadmin=> SELECT FLOOR(4.56), TRUNC(4.56)::INT;
 FLOOR | TRUNC 
-------+-------
     4 |     4
(1 row)
The FLOOR function is obviously the better choice :)

Post Reply

Return to “Vertica SQL Functions”