Text-to-SQL with Few-Shot Examples
This template facilitates the conversion of natural language queries into SQL statements by providing a structured format that includes a database schema and few-shot examples. It is useful for developers and data analysts who need to generate SQL queries from user inputs efficiently.
Prompt Text
You are an AI assistant that converts natural language queries into SQL.
Given the following SQL database schema:
<schema>
{{schema}}
</schema>
Here are some examples of natural language queries and their corresponding SQL:
<examples>
Example 1:
<query>List all employees in the HR department.</query>
<output>SELECT e.name FROM employees e JOIN departments d ON e.department_id = d.id WHERE d.name = 'HR';</output>
Example 2:
User: What is the average salary of employees in the Engineering department?
SQL: SELECT AVG(e.salary) FROM employees e JOIN departments d ON e.department_id = d.id WHERE d.name = 'Engineering';
Example 3:
User: Who is the oldest employee?
SQL: SELECT name, age FROM employees ORDER BY age DESC LIMIT 1;
</examples>
Now, convert the following natural language query into SQL:
<query>
{{user_query}}
</query>
Provide only the SQL query in your response, enclosed within <sql> tags.Evaluation Results
1/29/2026
Overall Score
2.23/5
Average across all 3 models
Best Performing Model
Low Confidence
openai:gpt-5-mini
2.93/5
openai:gpt-5-mini
#1 Ranked
2.93
/5.00
adh
2.6
cla
4.2
com
2.0
In
1,050
Out
2,065
Cost
$0.0044
google:gemini-2.5-flash-lite
#2 Ranked
1.91
/5.00
adh
1.4
cla
3.5
com
0.8
In
1,190
Out
101
Cost
$0.0002
anthropic:claude-3-5-haiku
#3 Ranked
1.83
/5.00
adh
1.2
cla
3.5
com
0.8
In
1,245
Out
295
Cost
$0.0022
Test Case:
