> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Run your first analysis

> 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.

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.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH orders(order_id, category, region, amount) AS (
  VALUES
    (1, 'Books',  'North', 20),
    (2, 'Games',  'South', 30),
    (3, 'Games',  'North', 15),
    (4, 'Books',  'North', 40),
    (5, 'Garden', 'South', 25),
    (6, 'Garden', 'North', 10)
)
SELECT * FROM orders ORDER BY order_id;
```

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:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT * FROM orders WHERE region = 'North' ORDER BY order_id;
```

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.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH orders(order_id, category, region, amount) AS (
  VALUES
    (1, 'Books',  'North', 20),
    (2, 'Games',  'South', 30),
    (3, 'Games',  'North', 15),
    (4, 'Books',  'North', 40),
    (5, 'Garden', 'South', 25),
    (6, 'Garden', 'North', 10)
)
SELECT category, SUM(amount) AS sales
FROM orders
GROUP BY category
ORDER BY category;
```

| category | sales |
| - | -: |
| Books | 60 |
| Games | 45 |
| Garden | 35 |

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](https://docs.e6data.com/transformation/learn/query-data.md) for more SQL practice. You can also [build a dashboard](https://docs.e6data.com/transformation/learn/dashboard.md) with the same six orders.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.