# Retrieve and Reuse Data

Use this section when you need to run SOQL once and reuse the returned values across an S-Docs template.

This pattern is useful for sentences, headers, footers, calculations, and conditional output.

Use it when a full table would add noise, but the query result still drives document content.

{% hint style="info" %}
Named queries do not render rows by themselves. They store returned values so you can reference them later in the template.
{% endhint %}

### Start with the path that fits your goal

If you are new to named queries, start with the tutorial.

If you already know the output you need, use the how-to guide.

If you need exact syntax, structure, or supported patterns, use the reference.

<table data-column-title-hidden data-view="cards"><thead><tr><th>Title</th><th>Description</th><th data-card-target data-type="content-ref">Target</th></tr></thead><tbody><tr><td><strong>Getting Started with Named Queries</strong></td><td>Learn the core named query pattern, then reuse returned values across your template.</td><td><a href="/spaces/v7v0UNK83URKB2C83QVU/pages/tqs181Afl8WTwiVd1HDk">/spaces/v7v0UNK83URKB2C83QVU/pages/tqs181Afl8WTwiVd1HDk</a></td></tr><tr><td><strong>Advanced Data Retrieval with Named Queries</strong></td><td>Use aggregates, filters, offsets, and grouped results to return exactly the values you need from a named query.</td><td><a href="/pages/FsHZyVC9ZIh2m1F0FpsK">/pages/FsHZyVC9ZIh2m1F0FpsK</a></td></tr><tr><td><strong>Named Queries Reference</strong></td><td>Use the reference for exact syntax, supported patterns, and advanced named query behavior.</td><td><a href="/spaces/qNhwNwsut3uqS2daHMHX/pages/3CFv6L5fo0m8fFI00BXo">/spaces/qNhwNwsut3uqS2daHMHX/pages/3CFv6L5fo0m8fFI00BXo</a></td></tr></tbody></table>

### What you can do with retrieve and reuse data

* query a value once and reuse it across the template
* place returned values in sentences, headers, footers, and formulas
* return filtered, grouped, or aggregate results without rendering a table
* keep complex output cleaner by referencing saved query values

### Browse by topic

* [How to: Advanced Data Retrieval with Named Queries](/sdocs/advanced-template-logic/named-query/how-to-advanced-data-retrieval-with-named-queries.md)
* [Perform Calculations](/sdocs/advanced-template-logic/perform-calculations.md)
* [Use Conditional Logic](/sdocs/advanced-template-logic/conditional-logic.md)

### Related note

Use [Insert Data Tables](/sdocs/advanced-template-logic/related-lists.md) when you need repeating rows instead of reusable values inside template content.


---

# Agent Instructions: 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:

```
GET https://help.sdocs.com/sdocs/advanced-template-logic/named-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
