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.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: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
- Copy the complete summary example into Workbench.
- Run it and check the same three totals.
- Select Save / create → Saved query. Name it
Lesson - category sales. - Wait for Saved to server.
- Open Queries, find that name, and reopen it.
- Select Run. Check the three totals again.
Change one thing
AddWHERE 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 onlyLesson - category sales from Queries.