0

I want to display the decimal precision along with the result for decimal datatype in hive. However if there is no fraction part , in hive it will not display the decimal points.

hive> select cast(11 as decimal(14,2));
11

hive> select cast(11.22 as decimal(14,2));
11.22

In the above example instead of 11 it should display 11.00.How to achieve this? Please help.

nobody
  • 10,892
  • 8
  • 45
  • 63
Dileep Dominic
  • 499
  • 11
  • 23

2 Answers2

1

The following format_number() function should do it.Source, return type will be string though.

select format_number(11,2)

Note: Precision and Scale were added from Hive 0.13.

nobody
  • 10,892
  • 8
  • 45
  • 63
-1

Use round or float_number to set the decimal point where u like , example :

select round(SUM(150.100 + 127.0090), 2);

  • or

select float_number(var,2);