Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

question regarding ' rounding figures ' using SQL

SmithJohn45Mar 8 2022

please have a look at below SQL statement, it is working fine as required, but is there any problem i failed to understand to handle or any better way to achieve.
round to 10 ( forward and/or backward)

with dt as (Select 247 num from dual),
   et as (select num, num - floor(num/10)*10 nums from dt)
select case when et.nums > 5 then
      floor(et.num/-10)*-10
    else
      floor(et.num/10)*10
  end results
from et;

this will result as: 250 --rounded to forward 10--
here CASE's first condition matched " et.nums > 5 "
regards

This post has been answered by Solomon Yakobson on Mar 8 2022
Jump to Answer
Comments
Post Details
Added on Mar 8 2022
8 comments
137 views