# Understanding and Editing the SQL Query

**Key Features of the SQL Section**

#### **1. Editing the SQL Query**

* The SQL query displayed here is either:
  * **AI-generated** based on the selected intent and data sources.
  * **User-defined** if imported from the Data Explorer flow.
* Users can modify the query manually if they need to adjust the dataset.

<figure><img src="https://2441185785-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeTNY9XuZbora2UmeM4sm%2Fuploads%2FOuAxjrAw6Pya66flnTf9%2Fimage.png?alt=media&#x26;token=d651c541-974d-4079-b8a3-e88f4177e959" alt=""><figcaption></figcaption></figure>

***

#### **2. Executing the SQL Query**

* Click **"Execute"** to run the query.
* The system will process the query using the **syntax of the selected data source**.

<figure><img src="https://2441185785-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeTNY9XuZbora2UmeM4sm%2Fuploads%2FV0FNYCPJdjElTtwtlp8F%2Fimage.png?alt=media&#x26;token=3016fb8e-de20-4807-b187-7061f928a4aa" alt=""><figcaption></figcaption></figure>

***

#### **3. Viewing the Query Results**

* The **Data Table** section displays the results of the executed query.
* This provides a preview of the dataset before applying it to the chart.

<figure><img src="https://2441185785-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeTNY9XuZbora2UmeM4sm%2Fuploads%2FxERB8A14DYjfryfSOoeu%2Fimage.png?alt=media&#x26;token=a4d34ce9-bced-4e7f-83a1-436ab503e6ca" alt=""><figcaption></figcaption></figure>

***

#### **4. Handling Errors & Fixing Issues**

* If there is a **syntax error**, an error message will be displayed.
* The system will provide a **prompt to fix the error**.
* You can manually edit the query or use the AI assistant for corrections.

<figure><img src="https://2441185785-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeTNY9XuZbora2UmeM4sm%2Fuploads%2FESuI4kROAEncpjAp2pGp%2Fimage.png?alt=media&#x26;token=37cd5ff0-8c7e-4b9c-bc1f-625d2d80e54e" alt=""><figcaption></figcaption></figure>

***

#### **5. Applying the Query to the Chart**

* Once the query is **error-free**, click the **"Apply"** button.
* This step is **mandatory** as it provisions the dataset for chart customization.

📌 *Without applying the dataset, the chart cannot proceed to customization.*

<figure><img src="https://2441185785-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeTNY9XuZbora2UmeM4sm%2Fuploads%2FveWmH05MlCK5j97PglHW%2Fimage.png?alt=media&#x26;token=0941cb7e-68d6-4912-9224-1ac6f692faa3" alt=""><figcaption></figcaption></figure>

***

#### **6. Navigating Back to Data Explorer**

* Clicking the **"Explorer"** button takes you back to the **Data Explorer flow**.
* This allows users to refine their dataset before finalizing the chart.

***

### **Next Steps: Customizing Your Chart**

Once the query is successfully applied, you can move to the **Chart Customization** section to configure the visualization settings. 🚀
