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
Duration
5s
Input Tokens
1038
Output Tokens
239
Cost
$0.00
Context
Input
I am in the class with teacher Amanda Svensson, I can't find the link to the video for the last lesson. Can you provide me with it?
Expected output
SELECT l.video_url FROM lessons l JOIN courses c ON l.course_id = c.course_id JOIN users u ON c.instructor_id = u.user_id WHERE u.name = 'Amanda Svensson' AND l.order_index = (SELECT MAX(order_index) FROM lessons l2 WHERE l2.course_id = c.course_id);
Model output
WITH amanda_id AS (
    SELECT user_id FROM users WHERE name = 'Amanda Svensson'
),
course_ids AS (
    SELECT course_id FROM courses WHERE instructor_id = (SELECT user_id FROM amanda_id)
),
last_lesson AS (
    SELECT lesson_id FROM lessons
    WHERE course_id = (SELECT course_id FROM course_ids)
    ORDER BY order_index DESC
    LIMIT 1
)
SELECT video_url FROM lessons WHERE lesson_id = (SELECT lesson_id FROM last_lesson);