Is there any function which return the next multiples of 10 value directly ?

Ex : input - 11 then it should return 20

156 - 160

299 - 300

43 - 50

Thanks

Saipradyumn

]]>

Is there any function which return the next multiples of 10 value directly ?

No such inbuilt function, however, you can write a SQL to achieve your task. Should be quite simple.]]>

SQL> With mydata As 2 ( Select 11 thevalue from dual union all 3 Select 156 from dual union all 4 Select 199 from dual union all 5 Select 44 from dual 6 ) 7 Select thevalue 8 , ceil(thevalue/10)*10 roundup 9 From mydata 10 / THEVALUE ROUNDUP ---------- ---------- 11 20 156 160 199 200 44 50

MHE]]>

Tell me and I'll forget; show me and I may remember; involve me and I'll understand

Regards

Michel

]]>

MHE

]]>

(In addition, with more than 300 posts and 2 years here she would know she have to post a test case with her question.)

Regards

Michel

]]>

1* select round(241,-1) + 10 from dual;

ROUND(241,-1)+10

----------------

250]]>

SQL> select round(245,-1) + 10 from dual; ROUND(245,-1)+10 ---------------- 260

Regards

Michel

]]>

orclz> orclz> select 241 +10 - mod((241+10),10) from dual; 241+10-MOD((241+10),10) ----------------------- 250 orclz>

--update, jw

or better,

orclz> select 241 + 10 - mod(241,10) from dual; 241+10-MOD(241,10) ------------------ 250 orclz>

Anyway:

SQL> With mydata As 2 ( Select 11 thevalue from dual union all 3 Select 156 from dual union all 4 Select 199 from dual union all 5 Select 44 from dual 6 ) 7 Select thevalue 8 , trunc(thevalue,-1)+10 roundup 9 From mydata 10 / THEVALUE ROUNDUP ---------- ---------- 11 20 156 160 199 200 44 50

Thanks for the code Maaher!]]>

orclz> ed Wrote file afiedt.buf 1 With mydata As 2 ( Select 11 thevalue from dual union all 3 Select 156 from dual union all 4 Select 199 from dual union all 5 Select 44 from dual 6 ) 7 Select thevalue 8 , to_number(substr(to_char(thevalue),1,length(to_char(thevalue)) - 1)||'0')+10 9* From mydata orclz> / THEVALUE TO_NUMBER(SUBSTR(TO_CHAR(THEVALUE),1,LENGTH(TO_CHAR(THEVALUE))-1)||'0')+10 ---------- -------------------------------------------------------------------------- 11 20 156 160 199 200 44 50 orclz>]]>

SQL> With mydata As 2 ( Select 10 val from dual union all 3 Select -21 from dual union all 4 Select -35.2 from dual union all 5 Select 156.1 from dual union all 6 Select 199 from dual union all 7 Select 44 from dual 8 ) 9 Select val 10 , decode(sign(val), '-1', -1*floor(abs(val)/10), ceil(val/10))*10 roundup 11 From mydata 12 / VAL ROUNDUP ---------- ---------- 10 10 -21 -20 -35.2 -30 156.1 160 199 200 44 50 6 rows selected.

]]>

1 With mydata As 2 ( Select 10 val from dual union all 3 Select -21 from dual union all 4 Select -35.2 from dual union all 5 Select 156.1 from dual union all 6 Select 199 from dual union all 7 Select 44 from dual 8 ) 9 Select val 10 , decode(sign(val), '-1', -1*ceil(abs(val)/10), ceil(val/10))*10 roundup 11* From mydata orclz> / VAL ROUNDUP ---------- ---------- 10 10 -21 -30 -35.2 -40 156.1 160 199 200 44 50 6 rows selected. orclz>This has to be the best solution. Though as Sai has not responded to any of this, I suppose she has lost interest. Or perhaps she found the references to domestic animals to be little off-putting.]]>

...if the results are conform to the generally accepted standard of "round away from zero":

Yeah, I wasn't sure what protocol the OP was following for that.

John Watson wrote on Wed, 11 September 2013 02:55

Though as Sai has not responded to any of this, I suppose she has lost interest. Or perhaps she found the references to domestic animals to be little off-putting.

Littlefoot wrote on Wed, 11 September 2013 02:41

(Catskinners, you'd better not be seen by Barbara!)

Those are pretty good!]]>