SQL CAST
Explicitly converts a value from one type to another — the standard SQL syntax for it.
What & Why
CAST(value AS type) explicitly converts a value to a different type. Some conversions happen automatically (like comparing a date column to a date-shaped string), but many others need to be requested explicitly with CAST.
See How It Works
BUSINESS QUESTION
A spend stored as text somewhere needs to become a real number before it can be used in arithmetic.
Convert text to a real numberStep 1 of 3
'55000'
| value | type |
|---|---|
| '55000' | text |
'55000' starts as text, so arithmetic is not valid yet.
EXAMPLE QUERY
SELECT CAST('55000' AS INTEGER) + 1000;Sign up free to try it on a real business scenario