SQL Flow Field Guide

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

  1. Read the input literals and the target type in each CAST.
  2. Trace each converted value to its output alias.
  3. Compare the integer and decimal results.

Check your work

ParsedQuantity is the integer 12. UnitPrice is decimal 3.00.

Practice SQL

Open in SQL Flow
SELECT 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