Describe Your Data Needs in English and Let Claude Write the SQL
Complex SQL is hard to get right. Describing what you want and having Claude write it — with your actual table names and relationships — is faster and less error-prone.
"I need monthly revenue by product category, excluding refunded orders, for Q4 2024"
Claude reads your database schema (through migrations, models, or an MCP database connection), then writes a query using your actual table and column names:
SELECT
c.name AS category,
DATE_TRUNC('month', o.created_at) AS month,
SUM(oi.price * oi.quantity) AS revenue
FROM order_items oi
JOIN orders o ON o.id = oi.order_id
JOIN products p ON p.id = oi.product_id
JOIN categories c ON c.id = p.category_id
WHERE o.created_at BETWEEN '2024-10-01' AND '2024-12-31'
AND o.status != 'refunded'
GROUP BY c.name, DATE_TRUNC('month', o.created_at)
ORDER BY month, revenue DESC;
This works for any complexity level:
# Simple lookups
"Find all users who signed up in the last 7 days but haven't verified their email"
# Complex aggregations
"Show the top 10 customers by lifetime value with their order count and average order size"
# Window functions
"Rank products by sales within each category and show the running total"
# Data investigation
"Find orders where the total doesn't match the sum of line items"
If you're using an ORM, ask Claude to write it in your framework's query builder instead:
"Write that as an Eloquent query, not raw SQL"
"Give me the Prisma version"
"Convert this to a Django ORM queryset"
Claude can also optimize existing slow queries — paste the SQL and your explain plan, and it rewrites the query or suggests indexes.
SQL is a language for machines. English is a language for humans — describe the data, let Claude write the query.
via Claude Code
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.