CAST function converts one built-in data type into another built-in data type with the specified precision and length.
Quick Example:
Convert a string value to NUMBER leaving 2 digits after the decimal point:
SELECT CAST('245.211' AS NUMBER(5,2)) FROM dual; -- Result: 245.21
You can use CAST function to convert a string value to number, and round it to the specified number of decimal digits:
SELECT CAST('245.205' AS NUMBER(5,2)) FROM dual; -- Result: 245.21 (note that the value is rounded, not truncated to 245.20)
Using CAST you can round numbers too:
SELECT CAST(245.205 AS NUMBER(5,2)) FROM dual; -- Result: 245.21