Reputation: 253
Not to truncate a table...In MySQL, I can use truncate(123.328,2)
to get 123.32
.
But how to do this in Hive
? I tried select cast(123.328 as decimal(10,2));
but it returns 123.33
; also tried floor()
but it only returns integer.
Any help is appreciated.
Upvotes: 1
Views: 162
Reputation: 1539
You can try this hack, hope this helps you.
You Multiply the number by 100 times, drop the decimals by Cast/format to BIGINT then divide the bigint by 100
select (CAST((123.328*100) AS BIGINT)/100);
Upvotes: 2