> For the complete documentation index, see [llms.txt](https://docs.upriverdata.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.upriverdata.com/product-usage/agent/query-editor.md).

# Query Editor

Write, run and save your own SQL queries alongside the agent.

The Query Editor tab of the [helper drawer](/product-usage/agent.md#the-helper-drawer) gives you a full SQL editor to run your own queries against a connected warehouse, independently of the agent — so you're never locked out of the data while the agent is doing the heavy lifting.

<figure><img src="https://875415170-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLE0zsJmUpeLjYw085cnO%2Fuploads%2Fgit-blob-cedcdbdfaa10f1800ae727d3a0969e3846990a5e%2Fimage%20(agent-sql-editor).png?alt=media" alt=""><figcaption><p>Query Editor with a query and its results</p></figcaption></figure>

## Layout

The tab is split vertically: the SQL editor on top, and results at the bottom. If your workspace has more than one connected warehouse, tabs at the top let you pick which one to run against.

## Running queries

* Give the query a title in the editable title field (defaults to "Untitled query").
* Click **Run** to execute the current statement, or use the dropdown arrow next to it to **Run all** statements in the editor.
* The Run button shows a spinner while the query executes, and is disabled if no warehouse is configured.

## Results

The results panel shows a status indicator and, once a query has run, the row count and duration, followed by the results rendered as a data table. Before any query has been run, it shows "No results yet — Run a query to see the output here."

If a query fails, a warning banner shows the error along with a **Fix with agent** button. Clicking it sends the failing query and its error back into the chat, asking the agent to help fix it.

## Managing queries

Each query tab has a "..." menu with:

* **Copy** — copy the query text.
* **Save query** — persist the query to your workspace's saved-query list.
* **Duplicate** — open a copy of the query in a new tab.
* **Rename**
* **Close tab** / **Delete saved query** — deleting a saved query asks for confirmation, since it can't be undone.

### Saved queries

Opening the Saved Queries dialog shows a searchable table of every saved query in your workspace, with its name, query text (hover to preview), creator and creation date. From here you can **Open query** (load it into a new or existing editor tab) or **Delete** it, and refresh the list at any time.

### Query history

A separate Query History tab lists previously run queries, independent of what's been explicitly saved, so you can find and re-open something you ran earlier even if you didn't save it.
