Text2SQL.ai logo

Insights

Published on

Insights provide a unified way to explore your data by combining SQL generation, query results, and visualizations in one place. Ask a question in plain English, and get the query, results, chart, and explanation all together.

Creating a New Insight

There are two ways to create a new insight:

  1. From the Sidebar

    • Click on the "New" button and then "New Insight"
    • Enter your question or request in natural language
    • Required - Select a database connection for context
    • Press Enter or click the "Generate" button to generate your insight
  2. From a Database Connection

    • Open a database connection
    • Use the "Create Insight" option
    • The connection context is automatically selected
    • Enter your question and create the insight

Understanding the Insight Interface

Each insight displays all relevant information in a unified view:

Left Side:

  • Insight Name - A readable title based on your question
  • SQL Query - The generated SQL code, syntax-highlighted and formatted
  • AI-Generated Description - A plain English explanation of what the query does

Right Side:

  • Results Table - The query results displayed row by row
  • Chart - An automatically generated visualization below the table

Everything is integrated and visible at once. You can review the query, check the raw data, and see the visualization without switching views or losing context.

Modifying Insights

You can modify the query or the chart independently by asking for changes in natural language. The AI maintains full context of your current insight, so you can refine:

  • Query - "Exclude test orders from this" or "Filter to only show orders from the last 30 days"
  • Chart - "Show this as a bar chart instead" or "Use a pie chart for this data"
  • Grouping - "Group by month instead of week" or "Group by product category"
  • Time Period - "Show data for the past year" or "Change to quarterly instead of monthly"

When you request a change, the AI updates only what's necessary—the query, results, chart, or description—while maintaining context throughout.

Query Version Control

All query modifications are version controlled. You can navigate back and forth through previous query versions at any time, allowing you to:

  • Compare different query approaches
  • Revert to a previous version if a change doesn't work as expected
  • Experiment with modifications knowing you can always go back

Best Practices

  1. Be Specific in Your Questions

    • Instead of "Show me sales," try "Show me total sales by product category for the last quarter"
    • Include time periods, filters, and grouping preferences in your initial question
    • Mention the type of visualization you prefer if you have one in mind
  2. Use Database Connections

    • Always select a database connection when creating an insight
    • The AI needs schema context to generate accurate queries
    • Make sure your connection has a detailed schema with comments for best results
  3. Iterate Gradually

    • Start with a broad question to see what data is available
    • Then refine with follow-up requests to narrow down or adjust the visualization
    • Each modification maintains context, so you can build on previous changes
  4. Review the Generated SQL

    • Check the SQL query to verify it matches your intent
    • Use the description to understand what the query does
    • This helps catch any misunderstandings before relying on the results

Example Use Cases

  1. Sales Analysis

    Question: Show me monthly revenue trends for the past year
    
    The insight generates:
    - A SQL query that groups sales by month
    - A line chart showing revenue trends over time
    - A table with monthly revenue figures
    - A description explaining the query logic
    
  2. Product Distribution

    Question: Give me a distribution of the most purchased products over the last six months
    
    The insight generates:
    - A SQL query that counts products and orders by product
    - A bar or pie chart showing product distribution
    - A table with product names and purchase counts
    - A clear explanation of the distribution calculation
    
  3. Customer Segmentation

    Question: Show me customer acquisition by region for the last quarter
    
    The insight generates:
    - A SQL query that groups customers by region and time period
    - A chart visualizing regional customer growth
    - A table with detailed regional breakdowns
    - Context about how acquisition is calculated
    

Accessing and Managing Insights

To access your previous insights:

  1. Open the Sidebar - Click on "Insights" in the sidebar
  2. Browse All - Click "Browse All" under Insights in the sidebar
  3. Search and Filter - Use the search function to find specific insights by name or content
  4. Manage Insights - From the browse view, you can:
    • Click on any insight to open and view it
    • Rename insights to better organize your work
    • Delete insights you no longer need
    • Edit insights by opening them and making modifications

This centralized view makes it easy to find, organize, and manage all your generated insights in one place.


Ready to create your first insight? Navigate to the Insights section in the app and start exploring your data. If you need help setting up a database connection, check out our Database Connections guide.