Read values with their data types
Use explicit casts to make the type of a value clear.
What you are trying to do
A file import contains a quantity as text. A small check should convert it to an integer and keep a price exact to two decimal places.
Work through it
- Read the input literals and the target type in each CAST.
- Trace each converted value to its output alias.
- Compare the integer and decimal results.
Check your work
ParsedQuantity is the integer 12. UnitPrice is decimal 3.00.
Practice SQL
Open in SQL FlowSELECT CAST(N'12' AS int) AS ParsedQuantity, CAST(3 AS decimal(5, 2)) AS UnitPrice;
Knowledge check
Commands in this lesson
Next lesson See how NULL changes a filter