CodingUpdated 2026-10-24
SQL Query Prompt
Turn a schema and a business question into readable, verifiable SQL.
#SQL#数据#分析#数据库DeepSeekClaude CodeCursor
Prompt
Write SQL from the schema below.
Database: {{database}}
Schema:
{{schema}}
Business question: {{question}}
Requirements:
1. Restate your interpretation and list assumptions.
2. Provide formatted SQL with aliases.
3. Explain each JOIN and filter.
4. Cover two edge cases: nulls, duplicates or time zones.
5. Provide validation queries for sampling and reconciliation.Variables to replace
{{数据库类型}}{{表结构}}{{问题}}
Example output
Assumption: one user can have multiple orders; the metric counts distinct users.
How to use it
Spell out the metric definition separately; it prevents SQL that is syntactically right but business-wrong.
Recommended tools
Related prompts
CodingFeatured
Code Review Prompt
Have the model review code by severity and return actionable fixes.
Claude CodeCursorGitHub Copilot
Coding
Unit Test Generation Prompt
Generate runnable tests with edge cases, not just the happy path.
Claude CodeCursorAider
Coding
Code Refactor Prompt
Get a step-by-step refactor plan with behavior-preserving verification.
Claude CodeCursorAider