examples/text-to-sql-agent/skills/query-writing/SKILL.md
For straightforward questions about a single table:
sql_db_schema to see columnssql_db_queryFor 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.
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;
If a query fails or returns unexpected results: