Skip to main content
TutorialApplies to: Unified engine deployments
Query six orders, filter them by region, group sales by category, and save the analysis. You will finish with three category totals and a query you can reopen.

Before you start

You need a running SQL engine and Workbench access. Saving also needs the saved-query capability. No catalog or sample-data setup is needed. The example uses whole-number amounts in one currency. It has six orders with total sales of 140. North has four orders worth 85. South has two orders worth 55.

1. Inspect the orders

Copy the SQL below into Workbench and run it. Wait for Succeeded and inspect the result table.
Expect six rows, with order IDs 1 through 6. WITH defines a named input for this statement only. It does not create a stored table.

2. Filter the result

In the Workbench editor, change the final SELECT to:
Keep the WITH block above it. This short SELECT depends on that block; it cannot run alone. Run the edited example. Expect order IDs 1, 3, 4, and 6, with amounts 20, 15, 40, and 10.

3. Group sales by category

Run this complete statement. GROUP BY combines rows with the same category. SUM adds their amounts.
The three totals add up to 140. Use Explain in Workbench if you want to inspect the query plan. Explain does not replace the query result.

4. Save and reopen

  1. Copy the complete summary example into Workbench.
  2. Run it and check the same three totals.
  3. Select Save / create → Saved query. Name it Lesson - category sales.
  4. Wait for Saved to server.
  5. Open Queries, find that name, and reopen it.
  6. Select Run. Check the three totals again.
Opening a saved query does not execute it. The query stores SQL and settings. Each execution has its own result.

Change one thing

Add WHERE region = 'South' between FROM and GROUP BY in the complete summary query. Run it again. Expect Games = 30 and Garden = 25, with no Books row. Save the edit if you want the saved query to keep this filter.

Check the result

You have verified the original six rows, the North filter, the category totals, and the South totals. Reopen the saved query and confirm that its SQL matches the version you chose to keep.

Clean up

These examples create no catalog tables. Close their Workbench session when finished. Keep the saved query or delete only Lesson - category sales from Queries.

Continue

Continue to Query your first dataset for more SQL practice. You can also build a dashboard with the same six orders.
Last modified on November 4, 2026