1 | initial version |
The cast() function is used to convert the data type of a value or expression to another data type. The proper way to utilize the cast() function is as follows:
For example, to convert the value of a column named 'Price' from a string data type to a decimal data type, the following SQL query can be used:
SELECT CAST(Price AS DECIMAL(10,2)) FROM products;
In this example, the value of the 'Price' column will be converted to a decimal data type with a precision of 10 and a scale of 2.