> For the complete documentation index, see [llms.txt](https://cleyrop.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cleyrop.gitbook.io/docs/documentation-fr-en/le-druide/interroger-des-datasets.md).

# Query datasets

The Cleyrop Dataset Search tool automatically translates your questions into SQL queries and runs them on the datasets you have access to.

***

## Prerequisites

Before using the Dataset Search tool from Le Druide:

1. **Have an accessible dataset** : the dataset must be available in your project or in the catalog, and your user permissions must allow you to access it.
2. **Configure the token** : the Dataset Search tool requires an access token. Generate it from your **Personal space → Profile & Tokens**, then enter it in the tool configuration via the ⚙️ button in Le Druide.

## Accessible datasets

You can query **any dataset your user account has access to** on the platform. The tool respects your access rights: it cannot query datasets for which you do not have read permissions.

You can ask the tool to list your available datasets before you begin.

{% hint style="warning" %}
The more datasets you have access to, the longer the list may take to appear.
{% endhint %}

## Available features

The Dataset Search tool lets you interact with your data in several ways:

| Capability                  | What the tool does                                                    | Example question                                               |
| --------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------- |
| **Schema exploration**      | Describes the structure of a dataset (columns, types, example values) | Describe the schema of the sales\_results dataset for me.      |
| **Data retrieval**          | Generates a `SELECT` on your data                                     | "Show me the 10 most recent sales."                            |
| **Filtering**               | Builds a `WHERE` clause to filter the results                         | "List the sales with revenue greater than €5,000."             |
| **Aggregations**            | Uses `GROUP BY` and `SUM`, `AVG`, `COUNT`...                          | "What is the total revenue by region for 2024?"                |
| **Joins**                   | Joins several tables and aggregates the results                       | "Give me the product categories and their total revenue."      |
| **Time-based queries**      | Uses date functions to group by period                                | "How many sales per month in 2023?"                            |
| **Statistics**              | Calculates `AVG`, `STDDEV` and other indicators                       | "What is the average value and standard deviation of revenue?" |
| **Top-N / Bottom-N**        | Uses `ORDER BY ... DESC LIMIT N`                                      | "What are the top 5 sales?"                                    |
| **Conditional logic**       | Adds conditions `CASE` or `WHERE` on complex criteria                 | "Which sales were made on a Friday?"                           |
| **Cross-table comparisons** | Runs several queries and compares the results                         | "Compare last year's revenue with this year's."                |

{% hint style="info" %}
**Note:**

* Read-only: the tool can only read data; it cannot modify or delete it.
* Simplified SQL: very complex queries (recursive CTEs, nested subqueries) may be truncated or simplified.
  {% endhint %}

## Download the result of a query on a dataset

When a question concerns a dataset you have access to, Le Druide runs SQL queries to find the requested information. The process of this search is visible in the conversation, and the result can be retrieved as a file.

1. From Le Druide, make a request by mentioning the **techname** of the dataset concerned.
2. See the details of the search in the **collapsible block** : datasets analyzed and SQL queries executed.
3. Download the **file** corresponding to the query result.

{% hint style="warning" %}
This feature relies on the Tool **Cleyrop Dataset**. A file provided as an attachment is not interpreted as a dataset: no SQL query is generated and the result is not downloadable in that case.
{% endhint %}

***

## Best practices

* **Mention the dataset name** : if you know it, specify it in your question (e.g., `sales_results`). Otherwise, ask the tool to list the available datasets or describe a dataset's schema.
* **Name the columns** : if you need a specific metric, cite its exact name (e.g., "Show me `customer_id` and `revenue_usd` for customers with more than 5 purchases").
* **Ask natural-language questions** : no need to write SQL, phrase your question as you would to a colleague (e.g., "Which products sold best in Q2 2024?").
* **Add limits** : for large volumes of data, specify a limit in your question (e.g., "the first 20 rows") to get a faster response.
