SQL Generation

Turn plain-English questions into correct SQL against a schema. The skill behind analytics chat, natural-language dashboards, and 'just ask the database' interfaces.

75
Duration
4s
Input Tokens
1032
Output Tokens
109
Cost
$0.01
Context
Input
List the names of employees and how many vehicles each of them has sold, including employees with 0 sales.
Expected output
SELECT e.name, COUNT(s.sale_id) AS vehicles_sold FROM employees e LEFT JOIN sales s ON e.employee_id = s.employee_id GROUP BY e.name ORDER BY e.name;
Model output
SELECT e.name, COUNT(s.sale_id) AS vehicles_sold FROM employees e LEFT JOIN sales s ON e.employee_id = s.employee_id GROUP BY e.employee_id, e.name;