# AI prompts for data analysis: SQL, trends, and interpretation

> Prompt templates for data analysis tasks — generating SQL queries, interpreting results, spotting trends, and cleaning messy datasets.

Source: Promptea — https://www.promptea.me/en/guides/data-analysis-prompts · Language: English · Last updated: 2026-11-14

## Why data analysis prompts fail

- No schema provided: the model invents column names and table structures it doesn't have.
- Underspecified goal: 'analyze this data' can mean dozens of things — specify what decision the analysis should support.
- Missing constraints: no row limits, no date ranges, no filter criteria — the model guesses.
- No output format: data analysis results need a specific format (table, SQL query, bullet summary) or they become walls of text.
- No validation request: SQL can look correct and still have logic errors — always ask for a check step.

## Parameters that make data prompts reliable

- Always provide the schema: table name, column names, data types, and a 2-3 row sample.
- State the decision: 'The output will be used to decide [X]' gives the model the right level of detail to target.
- Specify output format: query only, table, or bullet list with key numbers.
- Ask for a logic check: 'Explain what the query does and flag any assumptions you made about the data.'
- For trend analysis: specify the time grain (daily/weekly/monthly) and the metric definition explicitly.

## Templates

### SQL query from plain-English requirements

```text
Write a SQL query for the following requirement.

Database: [PostgreSQL / MySQL / SQLite — specify]

Table schema:
Table name: [name]
Columns: [column_name (type), column_name (type), ...]
Sample rows (2-3):
[paste 2-3 rows]

Requirement:
[describe what the query should return in plain English]

Constraints:
- Filter to: [date range / status / category — specify or remove]
- Limit results to: [number] rows if no specific filter
- Sort by: [column and direction]

Output:
1. The SQL query.
2. A plain-English explanation of what it does (2-3 sentences).
3. Assumptions you made about the data.
4. Any edge cases this query does not handle.
```

[Open in Promptea](https://www.promptea.me/en/analyzer?prompt=Write+a+SQL+query+for+the+following+requirement.%0A%0ADatabase%3A+%5BPostgreSQL+%2F+MySQL+%2F+SQLite+%E2%80%94+specify%5D%0A%0ATable+schema%3A%0ATable+name%3A+%5Bname%5D%0AColumns%3A+%5Bcolumn_name+%28type%29%2C+column_name+%28type%29%2C+...%5D%0ASample+rows+%282-3%29%3A%0A%5Bpaste+2-3+rows%5D%0A%0ARequirement%3A%0A%5Bdescribe+what+the+query+should+return+in+plain+English%5D%0A%0AConstraints%3A%0A-+Filter+to%3A+%5Bdate+range+%2F+status+%2F+category+%E2%80%94+specify+or+remove%5D%0A-+Limit+results+to%3A+%5Bnumber%5D+rows+if+no+specific+filter%0A-+Sort+by%3A+%5Bcolumn+and+direction%5D%0A%0AOutput%3A%0A1.+The+SQL+query.%0A2.+A+plain-English+explanation+of+what+it+does+%282-3+sentences%29.%0A3.+Assumptions+you+made+about+the+data.%0A4.+Any+edge+cases+this+query+does+not+handle.&purpose=data&target=gpt)

### Trend analysis and interpretation

```text
Analyze the data below and identify meaningful trends.

Metric: [what is being measured]
Time grain: [daily / weekly / monthly]
Period: [start date] to [end date]
Decision this analysis supports: [one sentence on what you will decide with this]

Data:
[paste data as CSV, table, or bullet list]

Output:
1. The main trend in 1-2 sentences (direction, magnitude, notable changes).
2. Up to 3 specific observations worth investigating (not generic statements — name the exact time period or data point).
3. What the data does NOT tell you (limitations, missing context).
4. One follow-up question to answer before acting on this data.

Constraints:
- Do not speculate about causes unless the data explicitly supports it.
- If a trend has contradictory signals, note the contradiction instead of picking one.
- Keep the total response under 250 words.
```

[Open in Promptea](https://www.promptea.me/en/analyzer?prompt=Analyze+the+data+below+and+identify+meaningful+trends.%0A%0AMetric%3A+%5Bwhat+is+being+measured%5D%0ATime+grain%3A+%5Bdaily+%2F+weekly+%2F+monthly%5D%0APeriod%3A+%5Bstart+date%5D+to+%5Bend+date%5D%0ADecision+this+analysis+supports%3A+%5Bone+sentence+on+what+you+will+decide+with+this%5D%0A%0AData%3A%0A%5Bpaste+data+as+CSV%2C+table%2C+or+bullet+list%5D%0A%0AOutput%3A%0A1.+The+main+trend+in+1-2+sentences+%28direction%2C+magnitude%2C+notable+changes%29.%0A2.+Up+to+3+specific+observations+worth+investigating+%28not+generic+statements+%E2%80%94+name+the+exact+time+period+or+data+point%29.%0A3.+What+the+data+does+NOT+tell+you+%28limitations%2C+missing+context%29.%0A4.+One+follow-up+question+to+answer+before+acting+on+this+data.%0A%0AConstraints%3A%0A-+Do+not+speculate+about+causes+unless+the+data+explicitly+supports+it.%0A-+If+a+trend+has+contradictory+signals%2C+note+the+contradiction+instead+of+picking+one.%0A-+Keep+the+total+response+under+250+words.&purpose=data&target=claude)

## Frequently asked questions

### Which AI model is best for SQL generation?

For SQL generation, GPT and Claude are both strong. GPT tends to write cleaner queries quickly; Claude handles complex multi-step logic well and is more likely to flag ambiguities in the schema. For data interpretation, Claude's tendency to note uncertainty is useful — it will flag when the data doesn't support a strong conclusion instead of speculating.

### How do I avoid hallucinated column names in SQL prompts?

Always paste the exact schema — table name, column names, types, and at least 2 sample rows. The model cannot invent a name it can see in front of it. If you add the constraint 'Use only the column names listed in the schema above — do not invent new ones,' most models will respect it. For critical queries, ask it to list all column names it used and verify them against the schema.
