Cast an expression to a different type.
Section: Conditional, NULL, and Conversion Functions
Convert data types
sql
sql
SELECT CAST(total AS DECIMAL(12,2)) AS total_decimal
FROM invoices;Explanation
Explicit casts make query intent clearer and avoid implicit conversion surprises.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Conditional, NULL, and Conversion Functions
Replace NULL with fallback value
Return the first non-NULL value in a list.
Convert a value to NULL conditionally
Return NULL when two expressions are equal.