Skip to content
/ Chapter 9 · Query Debugging and Common Mistakes
Lesson 9.1 · garden_shop
Lesson 9.1

Reading SQL Error Messages

Error messages tell you what went wrong and often suggest the fix. The skill is slowing down to read them.

Everyone writes queries that fail. The difference between frustration and a quick fix is reading the error instead of panicking. SQL engines tell you what they choked on, and DuckDB often suggests the column you probably meant.

The query below won't run. Click Run first, read what comes back, and let the message guide your fix. You will see a "Referenced column… not found" error pointing at the real problem.

Pattern
-- DuckDB error messages point right at the problem:
-- Binder Error: Referenced column "prize" not found
-- Candidate bindings: "price"
Schema · Garden Shop Table · products 9 columns · 24 rows
Table · products

One row per product, with price, cost, and inventory levels.

9 columns · 24 rows
product_id int product_name text category_id int supplier_id int price decimal cost decimal quantity_on_hand int reorder_level int discontinued bool
Your task

The starter query is broken. Run it, read the error, and fix it so it returns the 5 most expensive products, their product_name and price, most expensive first.

·

Run your query to inspect the result.

Expected answer
  • Columns: product_name, price.
  • Rows: the 5 most expensive products.
  • The Fiddle-Leaf Fig leads at 32.