Explain SQL results
Explain SQL results takes the result of a database query (a table of rows and columns, or a number) and, with an AI model, turns it into a short, clear explanation that answers the question that was asked. That way, whoever asked gets an understandable answer instead of a table.
It usually goes at the end of a chain that starts with SQL Query Constructor, which writes the query, and continues with a component that runs it, such as SQL Executor.
When to use it
- Answer questions about sales, orders or stock in a chat with a clear sentence instead of a table.
- Send an understandable summary of a query result by email.
- Reply in each user’s language even when the database is in another language.
Configuration
| Field | What it does |
|---|---|
| Result from the execution of SQL query (required) | The result of the query. Connect it from the component that ran it. |
| User request (required) | The original question, so the explanation answers what was asked. |
| User Language (required) | The language of the explanation, for example English or español. |
| Connection | What to connect |
|---|---|
| LLM (required) | An AI model component, for example OpenAI. |
Output
The Explanation results output returns the explanation as a text message. Connect it to a chat output component, an email or any component that takes text.
Example
In the sales assistant of Distribuciones Norte, a sales rep asks: “How many orders has Talleres Ruiz placed this year?”. The query returns a single row with the number 14.
Explain SQL results receives that result in Result from the execution of SQL query, the question in User request and English in User Language, and replies with something like: “Talleres Ruiz has placed 14 orders so far this year.”
Good practices
- Always pass the original question in User request: without it, the model does not know which part of the result matters.
- Keep the result small from the query itself (for example with Top K in SQL Query Constructor): an explanation of hundreds of rows loses clarity.
Related components
- SQL Query Constructor: writes the query from the question.
- SQL Executor: runs the query.