Before you start
You need Workbench and a running SQL engine. Every example includes its own input rows. No catalog, files, credentials, or external data is needed. These queries create no stored tables. Copy the SQL into Workbench and run the statements in order. Compare the result with the table below the query.WITH names input data for one statement only. Each example can run on its own.
1. Read every row
What are the six orders?
VALUES supplies rows. WITH gives them a name for this statement.
Change one thing: Use ORDER BY id DESC. Order 6 appears first.
2. Choose columns
Which category belongs to each order?
SELECT controls the columns in the result.
Change one thing: Select only id. Expect six rows with one column.
3. Name result columns
How can we make result headings clearer?
AS gives a result column a readable name.
Change one thing: Change sales to order_value. Only the heading changes.
4. Calculate a value
What would a ten percent increase look like?
An explicit DOUBLE cast gives the calculation a floating-point input.
Change one thing: Change 1.10 to 2.0. Expect 20, 40, and 60.
5. Find distinct values
Which regions appear?
DISTINCT removes duplicate result rows.
Change one thing: Select DISTINCT category instead. Expect Books, Games, and Garden.
6. Limit and skip rows
Which orders are second and third by value?
OFFSET skips sorted rows. A tie-breaker makes the order stable.
Change one thing: Remove OFFSET 1. Expect orders 4 and 2.