For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations
Use this skill when you need to answer a question by writing and executing a SQL query.
The built-in write_todos tool can be used to plan your work, but:
answer-formatting skill).For straightforward questions about a single table:
sql_db_schema to see columnssql_db_queryanswer-formatting skill with:
sql_db_query (number, row list, etc.)answer-formatting as your final answer.For questions requiring multiple tables:
Use write_todos to break down the task:
Use sql_db_schema for EACH table to find join columns and needed fields.
Check all JOINs have conditions, GROUP BY is correct, then run query.
sql_code: the exact SQL you executedanswer: 1–3 sentences explaining what the result means for the questionresult: the raw DB result (number, list of rows, list of objects, etc.)SELECT
c.Country,
ROUND(SUM(i.Total), 2) as TotalRevenue
FROM Invoice i
INNER JOIN Customer c ON i.CustomerId = c.CustomerId
GROUP BY c.Country
ORDER BY TotalRevenue DESC
LIMIT 5;
answer-formatting skill. Do not end with intermediate thoughts or planning
messages; the final output should be the structured {sql_code, answer, result}.