> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nekt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Queries

> Write and manage SQL queries to process, aggregate, and analyze your data.

Our Queries module allows you to manipulate data using SQL.

Queries in Nekt combine the power and familiarity of SQL with our intuitive interface to help you build and deploy data pipelines efficiently.

Whether you're aggregating, joining, filtering, or reshaping data, the SQL Explorer provides all the tools you need while maintaining the simplicity and readability that SQL is known for.

<video src="https://public.nekt.ai/videos/transformations/sql.mp4" autoPlay muted loop playsInline preload="auto" className="w-full" />

### Creating a Query

Nekt makes it simple to write, test, and save queries from the SQL Explorer. Whether you're writing simple filters or complex multi-table joins, the interface provides all the tools you need to build and validate your SQL code.

#### **Step 1: Access the SQL Explorer**

You can access the SQL Explorer in two ways:

1. Navigate to the **Explorer** page in Nekt.
2. Go to **Queries** > **Add Query** > **SQL**

Once you're in the SQL Explorer, you'll find a clean, intuitive interface where you can write and test SQL queries. The Explorer provides access to all your available data tables and views.

[Open SQL Explorer](https://app.nekt.ai/explorer)

***

#### **Step 2: Build Your SQL Query**

You have two options for building your query:

1. **Write SQL Manually:**

   * Use the SQL editor to write your query from scratch
   * Leverage auto-completion and syntax highlighting
   * Access table schemas and column information directly in the interface

2. **Use AI Assistance:**
   * Describe what you want to achieve in natural language
   * Let our AI help you generate the appropriate SQL query
   * Review and modify the generated query as needed

**Best Practices:**

* Start with simple queries and build complexity gradually
* Test your query results before creating a transformation
* Use the query history to reference and modify previous queries

***

#### **Step 3: Save as a Query**

Once your SQL is working as expected:

1. Click the **Save as Query** button in the Explorer
2. Configure the query settings:
   * Set a name and description
   * Choose when the query should run
   * Configure any necessary parameters
3. Save the query to make it available for execution

The query will now be available in your Queries list, where you can:

* Edit the SQL directly
* Modify the schedule and settings
* Monitor execution history and performance

[View Queries](https://app.nekt.ai/queries)

***

### **Best Practices**

1. **Query Optimization:**

   * Use appropriate indexes and joins
   * Limit the data processed to only what's necessary
   * Consider query performance and resource usage

2. **Maintainability:**

   * Use clear, descriptive names for queries
   * Document complex SQL with comments
   * Break down complex logic into smaller, manageable queries

3. **Testing:**

   * Always test queries with sample data first
   * Verify results match your expectations
   * Check for edge cases and data quality issues

4. **Monitoring:**
   * Review query execution logs
   * Monitor query performance
   * Set up alerts for failed queries

***

### **Need Help?**

If you need assistance with SQL queries, our team is here to help. You can:

* Use the AI assistant in the Explorer for query generation and debugging
* Contact our support team for additional guidance
