ROUNDUP() function functionality avialable in excel equivalent in PostgreSql

Viewed 15

I want to implement ROUNDUP() functionality which is available in EXCEL.

I tried round and Ceil functions in postgresql. But i am getting different values.

select round(1577.025,2); --Output: 1577.03
select ceil(1577.025);
select round(272.291,2); -- Output: 272.29

In excel, ROUNDUP(272.291,2) function i am getting Output as 272.30. I tried Ceil function but it is not accepting decimals.

Same functionality i am expecting in PostgreSql. Please help me on this.

1 Answers

Check if this is working for you:

select ceil(:input * power(10,:decimal))/power(10,:decimal);

where :input is the decimal you want to roundup and :decimal is the place to which you want the roundup.

In PostgreSQL the round(..) function is only rounding up if the previous digit is >= 5, this is why you are getting different results.

Related