Four-example few-shot prompt for turning natural-language questions into SQL against a provided schema. Uses PostgreSQL syntax; includes an aggregation, a join, and a filter example.
npx mdskills install mdskills/sql-generation-few-shotRelated
Instruction + example input/output pairs
@mdskills? Sign in with GitHub to claim this listing.1Given the schema below, translate the natural-language question into a single PostgreSQL query. Do not include commentary.23Schema:4{schema}56Example 1:7Question: How many orders were placed last month?8SQL: SELECT COUNT(*) FROM orders WHERE created_at >= date_trunc('month', now() - interval '1 month') AND created_at < date_trunc('month', now());910Example 2:11Question: What are the top 5 customers by total spend?12SQL: SELECT c.name, SUM(o.total) AS spend FROM customers c JOIN orders o ON o.customer_id = c.id GROUP BY c.name ORDER BY spend DESC LIMIT 5;1314Example 3:15Question: Which products have never been ordered?16SQL: SELECT p.id, p.name FROM products p LEFT JOIN order_items oi ON oi.product_id = p.id WHERE oi.id IS NULL;1718Example 4:19Question: Show the average order value by month for 2026.20SQL: SELECT date_trunc('month', created_at) AS month, AVG(total) AS avg_order FROM orders WHERE created_at >= '2026-01-01' AND created_at < '2027-01-01' GROUP BY month ORDER BY month;2122Now translate:23Question: {question}24SQL:
Full transparency — inspect the skill content before installing.