CodeIntermediateAwaiting test

SQL query from a business question

Translate a question into safe SQL.

Prompt

Database schema:
{{schema}}
Write one SQL query that answers: “{{question}}”. Use only tables and columns in the schema. Explain each clause in one line. State any assumption (e.g. time zone, what counts as “active”). Use parameters (?) for any user-provided value. Do not modify data (SELECT only).

Fill the variables

Result

Database schema:
{{schema}}
Write one SQL query that answers: “{{question}}”. Use only tables and columns in the schema. Explain each clause in one line. State any assumption (e.g. time zone, what counts as “active”). Use parameters (?) for any user-provided value. Do not modify data (SELECT only).

Example

Input: schema = orders(id, created_at, total_fils, status); question = revenue per month this year

Expected output: A SELECT with GROUP BY and explanations.