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
27s
Input Tokens
960
Output Tokens
318
Cost
$0.00
Context
Input
Which students joined this year and already finished a lesson?
Expected output
SELECT DISTINCT u.name FROM users u JOIN completions c ON u.user_id = c.user_id WHERE u.role = 'student' AND u.created_at >= DATE_TRUNC('year', CURRENT_DATE);
Model output
SELECT u.*
FROM users AS u
WHERE u.role = 'student'
  AND date_part('year', u.created_at) = date_part('year', CURRENT_DATE)
  AND EXISTS (
        SELECT 1
        FROM completions AS c
        WHERE c.user_id = u.user_id
    );