How to add the decimal point based on the condition in oracle?

52 Views Asked by At
select case when country='USA' then to_number(value,10,3) else to_number(Value,10,2) from emp_country;

Table Creation:

create table emp_country ( PersonID int, Country varchar(25), Value number(30,5) );

current output:

personid country value

12 USA 123.45

13 INR 125.09

14 USA 234.09

15 UK 123.45


Expected output:

personid country value

12 USA 12.345

13 INR 125.09

14 USA 23.409

15 UK 123.45

TO_char is not working and getting error like ORA-01722: invalid number , getting the error

0

There are 0 best solutions below