Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

round,ceiling 2 decimal points

I want to round up some figures that have 2 decimals points to 1. However, I always want it to round 1 examples of the list of figures in column amount

140.08 = 140.1
141.63 = 141.7

if I use round(141.63,1) it equals 142.6, but I want all the decimal points to round up, similar to the ceiling function. I want 141.7

Any help would be great?

thanks Don

like image 617
Don Mercer Avatar asked Oct 06 '17 05:10

Don Mercer


People also ask

What does round answer to 2 decimal places?

Rounding a decimal number to two decimal places is the same as rounding it to the hundredths place, which is the second place to the right of the decimal point. For example, 2.83620364 can be round to two decimal places as 2.84, and 0.7035 can be round to two decimal places as 0.70.

What is the ceiling of a decimal?

Ceiling(Decimal) Returns the smallest integral value that is greater than or equal to the specified decimal number.

How do you round to 2 decimal places in SQL?

Using ROUND() function with a variable and getting the rounded number to -2 decimal place.


1 Answers

you can try this.

select ceiling(141.63 * 10) / 10.0 ,
       ceiling(140.08 * 10) / 10.0

Result

141.700000                              
140.100000
like image 91
Serkan Arslan Avatar answered Sep 24 '22 02:09

Serkan Arslan