> For the complete documentation index, see [llms.txt](https://docs.coherent.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coherent.global/assistant/agent/workflows/work-with-tables-and-sql.md).

# Work with tables and SQL

Agent can help summarize table-style data. You can ask questions such as "group this by month" or "show the top 10 customers," and Agent can use SQL when that is the best way to answer.

Use this workflow when your data is arranged in rows and columns and you need a structured summary, filter, join, or calculation.

## When to use this workflow

Use this workflow when your data is arranged in rows and columns and you want to filter, group, join, or summarize it.

Good examples include:

* Summarizing transactions by month, region, or customer.
* Finding duplicate records.
* Combining data from two sheets or attachments.
* Creating a summary table for later use.
* Checking missing values or inconsistent categories.

## Example prompts

* "Create a table from the selected range and summarize revenue by region."
* "Find the top 10 customers by revenue."
* "Join these two attached CSV files and return the matching rows."
* "Use `Sales!A1:H500` and count rows by status."
* "Check this table for duplicate invoice IDs and missing amounts."

## Recommended steps

1. Select the source range or name the sheet and range.
2. Ask Agent to check the headers and data types.
3. Ask for the summary, filter, join, or calculation you want.
4. Review the result and ask for a saved output if you need to reuse it.
5. If the result should be written to the workbook, ask for a preview first.

## Make table requests precise

When possible, name the columns Agent should use. This reduces ambiguity when a table has similar fields.

For example:

> Use `Sales!A1:H500`. Group by `Region` and `Invoice Month`, sum `Revenue`, and return the top five regions by total revenue.

## Tip

This works best when the source range has clear headers and consistent column types.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coherent.global/assistant/agent/workflows/work-with-tables-and-sql.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
