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.

50
Duration
2s
Input Tokens
1190
Output Tokens
254
Cost
$0.00
Context
Input
Hi I'm Oscar that enrolled in 2018, I don't remember what courses I completed, can you help me?
Expected output
SELECT DISTINCT c.title FROM users u JOIN enrollments e ON u.user_id = e.user_id JOIN lessons l ON l.course_id = e.course_id JOIN completions cp ON cp.lesson_id = l.lesson_id AND cp.user_id = u.user_id JOIN courses c ON c.course_id = l.course_id WHERE u.name ILIKE '%oscar%' AND DATE_TRUNC('year', e.enrolled_at) = DATE '2018-01-01';
Model output
SELECT DISTINCT T2.title FROM users AS T1 INNER JOIN enrollments AS T3 ON T1.user_id = T3.user_id INNER JOIN courses AS T2 ON T3.course_id = T2.course_id WHERE T1.name = 'Oscar' AND T3.enrolled_at >= '2018-01-01' AND T3.enrolled_at < '2019-01-01' AND T3.status = 'completed'