SQL

Natural language to SQL query generation evaluates text-to-query fidelity and schema reasoning. This task is particularly relevant for analytics chat assistants and simplified database interfaces where users need to query data using natural language. Models must understand both the intent behind the question and the structure of the underlying database schema.

100
Duration
9s
Input Tokens
968
Output Tokens
778
Cost
$0.00
Context
Input
Who are the instructors making the most money from enrollments? Give me a list (instructor_name) and total earnings (total_earnings) sorted by their earnings please.
Expected output
SELECT u.name as instructor_name, SUM(p.amount) AS total_earnings FROM payments p JOIN enrollments e ON p.enrollment_id = e.enrollment_id JOIN courses c ON e.course_id = c.course_id JOIN users u ON c.instructor_id = u.user_id GROUP BY u.name ORDER BY total_earnings DESC;
Model output
SELECT 
    u.name AS instructor_name,
    COALESCE(SUM(p.amount), 0) AS total_earnings
FROM 
    users u
JOIN 
    courses c ON u.user_id = c.instructor_id
LEFT JOIN 
    enrollments e ON c.course_id = e.course_id
LEFT JOIN 
    payments p ON e.enrollment_id = p.enrollment_id
WHERE 
    u.role = 'instructor'
GROUP BY 
    u.user_id, u.name
ORDER BY 
    total_earnings DESC;