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
Use CASE expression
Return different values based on conditions.
OpenIn sheetsqlsame section
Replace NULL with fallback value
Return the first non-NULL value in a list.
OpenIn sheetsqlsame section
Convert a value to NULL conditionally
Return NULL when two expressions are equal.
OpenIn sheetsqlsame section
Cast timestamp to date
Remove the time portion from a timestamp.
OpenIn sheetsql1 tag match
Concatenate strings
Join multiple strings into one value.
Get current date and timestamp
Return the current date and current timestamp.