Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Hive How to round off to 2 decimal places?

Tags:

hadoop

hiveql

Actually I'm looking for more details about the sum function in Apache Hive. Until now, I understood that I can specify the number of digits after the dot:

val DECIMAL(18, 3)

But what I can not find is the precision scale in case of sum. If I add 2 decimals with a precision scale of 3 for example, what will be the return of the sum function? My precision scale will be preserved? The result will be truncated or rounded? What have I missed?

Thanks a lot.

like image 525
Régis NIOX Avatar asked Jan 08 '16 08:01

Régis NIOX


People also ask

How do you keep a float up to 2 decimal places?

format("%. 2f", 1.23456); This will format the floating point number 1.23456 up-to 2 decimal places, because we have used two after decimal point in formatting instruction %.

How do you round to 2 decimal places in node JS?

Use the toFixed() method to round a number to 2 decimal places, e.g. const result = num. toFixed(2) . The toFixed method will round and format the number to 2 decimal places.

How do you round off to 2 decimal places?

Round 3.863 off to 2 decimal places. 2 decimal places means that the answer needs to have 2 numbers after the decimal point. Let’s highlight all the numbers up to 2 numbers after the decimal point: Now all you need to do next is look at the number after the 6 to decide if you round the number down (keep it the same as 3.86) or up (round to 3.87).

What is round 14 16 off to 2 decimal places?

Round 14.816 off to 2 decimal places. 2 decimal places means that the answer needs to have 2 numbers after the decimal point. Let’s highlight all the numbers up to 2 numbers after the decimal point: 14.81 6

What does 2 decimal places mean?

2 decimal places means that the answer needs to have 2 numbers after the decimal point. Let’s highlight all the numbers up to 2 numbers after the decimal point: Now all you need to do next is look at the number after the 0 to decide if you round the number down (keep it the same as 174.80) or up (round to 174.81).

How do you round to thousandths place?

Now, look at the digit on the right side of the place value you wanted to round to i.e. thousandths place. In this case, it is 8 Since 8 > 5 we will round up and increase the hundredths place by 1 i.e. 5+1 =6. Ignore the remaining digits in the decimal number.


1 Answers

Just round it to as many decimal places as you want.

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

Output of above will be:-

277.11
like image 120
Jack Daniel's Avatar answered Sep 22 '22 07:09

Jack Daniel's