Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding decimal point and zeroes in Oracle

Is there a way to specify that a double datatype will always have 2 points after the decimal point like currency usually has (oracle db) ?

that is:

100 will be converted to 100.00
101.1 will be converted to 101.10

Tried casting it and setting precision-scale but no luck with that it doesnt add default decimal point and zeroes

SELECT CAST((600.2) AS NUMERIC(28,2)) FROM DUAL;

Gives me 600.2

like image 320
Arah Avatar asked Feb 02 '26 17:02

Arah


1 Answers

SELECT to_char(101, '999.90') FROM DUAL;
SELECT to_char(101.1, '999.90') FROM DUAL;
like image 86
Sefer K Avatar answered Feb 05 '26 06:02

Sefer K