# Query Builder

### Overview:

Query Builder is Lumi AI's dedicated SQL development environment, enhanced with Lumi AI as a context-aware Copilot. It provides analysts with a code-first workspace to write, test, and iterate on SQL while leveraging AI assistance grounded in their organization’s Knowledge Base. This enables faster iteration, easier debugging, and more reliable insight generation.

### Key Capabilities/ Benefits :

* **Dedicated SQL Editor** – A full SQL development environment designed for analysts who want direct control over joins, filters, calculations, and query structure.
* **Contextual AI Copilot** – AI assistance that understands your schema, stored definitions, and business context to help extend or improve queries.
* **One-Click Debugging** – Automatically diagnose and resolve SQL errors with contextual suggestions surfaced directly in the editor.
* **Tracked Iterations** – Every query version is preserved, allowing analysts to experiment safely and revert to previous logic when needed.
* **Publishing to Boards** – Share validated queries directly to Boards to make insights visible across teams.
* **Alerts on Trusted Logic** – Configure alerts on queries so teams are automatically notified when important thresholds are reached.

***

## How to Use Query Builder

Step 1: Select the **"Query Builder"** feature on the left hand side of your navigation pane

<figure><img src="/files/0iDQV2ug2oneYd2iIeWK" alt=""><figcaption></figcaption></figure>

Step 2: Users can either click **"Start Code"** to begin writing SQL manually, or use the AI assistant to automatically generate a baseline query that they can review and modify.

<figure><img src="/files/d3FwJ4XTIbBhFGSjiP2m" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Below is an example of the SQL code generated by Lumi's AI CoPilot
{% endhint %}

<figure><img src="/files/Dztynap5d8r097x50RNw" alt=""><figcaption></figcaption></figure>

Step 3: Edit the generated SQL in the SQL Editor to customize the query and further enrich the results displayed in your visualization.

<figure><img src="/files/jGxY1nrSvmt3cRxAobj8" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If an error occurs, click **Debug** to automatically diagnose the issue and update your SQL query with the appropriate corrections.
{% endhint %}

<figure><img src="/files/FZ2X3KUNU4ySJLVaZkR2" alt=""><figcaption></figcaption></figure>

Step 4: Every update to your SQL query is automatically saved as a new iteration. Previous versions can be rerun or revisited, making it easier to track changes and maintain a reproduceable audit trail

<figure><img src="/files/DVyB7TvUuEcooLvrfluP" alt=""><figcaption></figcaption></figure>

Step 5: Once complete, you can publish the Board and share the insights with your team.

<figure><img src="/files/EwRlYi6uMhC7XqIMRYNG" alt=""><figcaption></figcaption></figure>


---

# 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://docs.lumi-ai.com/product-features/query-builder.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.
