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.

75
Input Tokens
0
Output Tokens
0
Duration
0
Cost
0
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 c.title FROM users u JOIN enrollments e ON u.user_id = e.user_id JOIN courses c ON e.course_id = c.course_id WHERE u.name = 'Oscar' AND EXTRACT(YEAR FROM e.enrolled_at) = 2018 AND e.status = 'completed';