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.

100
Duration
7s
Input Tokens
974
Output Tokens
167
Cost
$0.01
Context
Input
Find the name of the dealership that has the highest total revenue from vehicle sales
Expected output
SELECT d.name FROM dealerships d JOIN sales s ON d.branch_id = s.branch_id GROUP BY d.name ORDER BY SUM(s.sale_price) DESC LIMIT 1;
Model output
SELECT d.name
FROM dealerships d
JOIN (
    SELECT branch_id, SUM(sale_price) as total_revenue
    FROM sales
    GROUP BY branch_id
    ORDER BY total_revenue DESC
    LIMIT 1
) s ON d.branch_id = s.branch_id;