> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://mammoth.io/docs/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# Write SQL by hand and reuse SQL snippets in Mammoth

> Type your own DuckDB SQL in Ask in plain words, then save standard calculations and filters as snippets you insert by reference or paste as a fixed value.
>
> Applies to: Where: View › Describe your transformation › AI Powered › Ask in plain words › Show the SQL

You can skip the prompt in **Ask in plain words** and type the query yourself in **The SQL it will run**. Snippets let your team save a standard calculation or filter once and insert it into any query. For generating SQL from a request, see [Ask your data in plain words](https://mammoth.io/docs/learn/clean-and-shape/sql-with-ai/).

## Write a SQL query yourself

1. Open **Ask in plain words** and leave the prompt box empty.
2. Click **Show the SQL**.
3. Type or paste SQL in **The SQL it will run**.
4. Click **Apply**.

Use this when you know the query you want, or to adapt a query from another tool. When you open a task you wrote by hand, the SQL is already shown.

**SQL dialect:** queries are DuckDB SQL. Put column names with spaces or special characters in double quotes. The View name is the table name.

## Reuse SQL with snippets

A snippet is a saved piece of SQL, such as a standard calculation or filter your team uses often. Click **Show the SQL**, then **Insert Snippet**. Save common logic as snippets so the team uses the same logic.

![Insert Snippet menu open, showing No snippets available and a New Snippet link](https://mammoth.io/docs/images/20260605_092951_insert-snippet-panel1.webp)

## Create a SQL snippet

1. Click **New Snippet** in the snippets panel.
2. Enter a name and the SQL in the value field. The name must start with a letter or `_` and use only letters, digits and `_`. A description is optional.
3. Click **Create Snippet**.

Snippets can't reference other snippets.

## Insert a snippet into a query

| Option | What it inserts |
| --- | --- |
| **Reference** | The token `{{snippet_name}}`. It stays linked: Mammoth uses the snippet's current content when the query runs. |
| **Paste value** | The snippet's text, frozen, with no link back to the snippet |

If a snippet used by a saved query task changes, Mammoth marks that task as stale. Rerun the pipeline to use the new content. See [Parameters and snippets](https://mammoth.io/docs/learn/organise/parameters-and-snippets/).

## Related

- [Ask your data in plain words](https://mammoth.io/docs/learn/clean-and-shape/sql-with-ai/): generate and check the query.
- [Parameters and snippets](https://mammoth.io/docs/learn/organise/parameters-and-snippets/): manage snippets and parameters.
- [How the pipeline works](https://mammoth.io/docs/learn/clean-and-shape/how-the-pipeline-works/): task order, Draft mode and previews.

---
Source: https://mammoth.io/docs/learn/clean-and-shape/sql-by-hand.md · Updated: 2026-11-08
