Skip to main content
TutorialApplies to: Unified engine deployments
Use named steps and subqueries to make an analysis easier to read.

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. Chain named steps

What are the category totals for North?
Expected result Later CTEs can read earlier CTEs. A CTE is a common table expression: a named query step. Change one thing: Change North to South. Expect Games 30 and Garden 25.

2. Reuse a named step

Can one query compare region totals?
Expected result The same CTE can appear more than once with different aliases. Change one thing: Swap the region filters. Expect 55 and 85.

3. Use a derived table

Which categories have at least 45 sales?
Expected result A query inside FROM is a derived table. Give it an alias. Change one thing: Use sales >= 60. Only Books remains.

4. Use a scalar subquery

Which orders equal the largest amount?
Expected result This subquery supplies one value. Change one thing: Replace MAX with MIN. Expect order 6 with amount 10.

5. Test existence

Which customers have any sales?
Expected result EXISTS checks whether the inner query returns any rows. Change one thing: Use NOT EXISTS. Only Cy remains.

6. Filter with a subquery

Which orders belong to known customers?
Expected result IN compares against values returned by a query. Change one thing: Limit the inner query with WHERE id = 1. Expect orders 10 and 11.

Continue

Continue to Compare lists, or return to Learn Laminar.
Last modified on November 4, 2026