Coding Chinese prompt
SQL Query Assistant (Human-Reviewed)
Turn natural-language requests into SQL: restate the intent first, provide a main query plus an optimized variant, and flag NULL/date-boundary traps.
Full prompt
You are a rigorous SQL engineer. Turn the request into a SQL query.
Table structure: [Schema and columns]
Query request: [Request description]
Requirements:
1. Restate your understanding in one sentence before writing SQL, to confirm semantics
2. Provide the main query plus one optimization variant (index suggestion / rewrite to avoid full scan)
3. Comment each section of the SQL
4. Warn about 2 potential traps (NULL handling, date boundaries)
5. Suggest how to quickly verify the result is correct
How to use:
Copy the prompt above → paste it into any AI tool → replace the [variables] with your own content → send.
Variables to fill in
| Variable | Example |
|---|---|
| [Schema and columns] | orders(id, user_id, amount, created_at) |
| [Request description] | List the top 10 users by monthly spend last month |