Skip to content
/ Chapter 2 · Data Types Before Deep Querying
Lesson 2.1 · garden_shop
Lesson 2.1

Why SQL Data Types Matter

SQL uses column types to decide how values compare, sort, and calculate.

Every column has a type. A column might hold text, numbers, dates, booleans, or missing values. SQL uses those types when it sorts, compares, filters, and calculates.

The difference matters quickly. Sorting product names alphabetically is different from sorting product prices numerically.

ORDER BY sorts the result by a column, and DESC puts the largest value first, as in Lesson 1.6. Here it shows how a type behaves.

Pattern
select column_one, number_column
from table_name
order by number_column desc
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

Show each product's product name and price, sorted from the highest price to the lowest. Keep only the first 5 rows.

·

Run your query to inspect the result.

Expected answer
  • Columns: product_name, price.
  • Rows: 5 products.
  • The first row should be Fiddle-Leaf Fig at 32.