Search code examples
sqloracle-databaseplsql

What is the syntax in Oracle to round any number to the next number in Oracle database


What is the syntax in Oracle to round any number to the next number in Oracle Database even decimal number is less than 5 Eg:- By using round() function I'm able to get the next number only when the decimal is greater than 5 but I want the next number even though decimal in less than 5

value    Exp.Result
1.2      2
1.9      2
2.1      3

Thanks.


Solution

  • You want the CEILing function to round-up (towards positive infinity).

    SELECT value, CEIL(value)
    FROM   table_name;
    

    Which, for the sample data:

    CREATE TABLE table_name (value) AS
    SELECT 1.2 FROM DUAL UNION ALL
    SELECT 1.9 FROM DUAL UNION ALL
    SELECT 2.1 FROM DUAL;
    

    Outputs:

    VALUE CEIL(VALUE)
    1.2 2
    1.9 2
    2.1 3

    fiddle