Learn with Abdou

Chapter 10 · Concept 2 of 5 · Practice

The invalid rate hides behind zero

CAST, GLOB, why a CHECK cannot see the source · level 1 of 6

Opening your saved work…

Sign in to save across devices → · Download your guest work before switching accounts.

The invalid rate hides behind zero · CAST, GLOB, why a CHECK cannot see the source · level 1 of 6

The text beside its conversion

Level 1: Watch it answered · Exercise 1 of 1

Put each staged rate beside what CAST makes of it: serial, daily_rate and converted_rate for all six rows, in file order.

Data: Trail Gear: build rehearsal.

Why it works, clause by clause

  1. daily_rate is the text as it arrived: 8, 12, 9, -3, unknown and 10.
  2. CAST(daily_rate AS INTEGER) AS converted_rate: what a load would store. Five rows convert to the number you would expect.
  3. TG-105's unknown converts to 0. No error, no warning, and nothing in converted_rate says it was ever a word.

From the reading: CAST converts; it does not certify, paragraph 1

The queryOpening the database…
SELECT serial, daily_rate, CAST(daily_rate AS INTEGER) AS converted_rate
FROM stg_items
ORDER BY rowid;
Open in the playground

Query results

Run it to see the result here.

Run it to see the result here.

Practice here is evidence for you and your instructor, never a grade. Grades live in Canvas.