Data Analysis Prompting
Transform LLMs into powerful data analysis assistants for SQL, statistics, and insights
Turn Data Into Insights
LLMs can generate SQL queries, interpret complex datasets, describe visualizations, and perform statistical analysis. The key is providing clear context about your data structure and analysis goals.
SQL Query Generation
Provide Database Schema
LLMs need to understand your table structures, column names, data types, and relationships to generate accurate SQL.
You are a SQL expert. Generate a query based on the following schema:
Tables:
- customers (id, name, email, signup_date, plan_tier)
- orders (id, customer_id, order_date, total_amount, status)
- products (id, name, category, price)
- order_items (order_id, product_id, quantity, price)
Task: Find the top 10 customers by total spend in the last 6 months, showing their name, email, number of orders, and total spend. Sort by total spend descending.
Specify SQL Dialect
Different databases have different syntax. Always specify which SQL dialect you're using.
Include in prompt:
- • Database type (PostgreSQL, MySQL, SQL Server, etc.)
- • Version if relevant
- • Special requirements (use CTEs, avoid subqueries, etc.)
Example:
"Generate a PostgreSQL query using CTEs for better readability..."
Data Interpretation
Provide Context for Numbers
Raw data without context is meaningless. Help the LLM understand what the numbers represent and what's considered good or bad.
Analyze this customer churn data:
Month: Jan | Churn Rate: 3.2% | MRR Lost: $45,000
Month: Feb | Churn Rate: 4.1% | MRR Lost: $58,000
Month: Mar | Churn Rate: 5.8% | MRR Lost: $82,000
Context:
- Our target churn rate is below 3%
- Industry average is 5-7% for our segment
- We launched a price increase in February
Provide insights on the trend, severity, and potential causes.
Ask for Specific Insights
Don't just ask "what do you see?" — direct the LLM toward the types of insights you need.
❌ Vague:
"Analyze this data."
✓ Specific:
"Identify anomalies, seasonal patterns, and any metrics that deviate >20% from the 6-month average."
Chart & Visualization Descriptions
Describe the Chart Type Needed
LLMs can recommend or describe appropriate visualizations if you explain your data and goals.
I have this dataset:
- Product categories (5 categories)
- Monthly revenue per category over 12 months
- Total revenue per month across all categories
Tasks:
- Recommend the best chart type to show category performance trends over time
- Suggest a second visualization to show each category's contribution to total revenue
- Describe what insights each chart would reveal
Statistical Analysis Requests
Specify the Statistical Test
If you know which test you need, state it clearly. If not, describe your hypothesis and let the LLM recommend.
I ran an A/B test with these results:
Control (A): 10,000 users, 850 conversions (8.5%)
Variant (B): 10,000 users, 920 conversions (9.2%)
Tasks:
- Recommend the appropriate statistical test
- Calculate if the difference is statistically significant (α = 0.05)
- Explain the results in plain English
Request Plain-English Explanations
Statistical results are useless if stakeholders can't understand them. Always ask for interpretation.
Add to your prompts:
- • "Explain the results as if presenting to executives with no statistics background"
- • "Include what this means for business decisions"
- • "Provide confidence levels in plain language (e.g., 'highly confident', 'moderately confident')"
Data Analysis Best Practices
DO: Validate SQL Before Running
Always review generated SQL for correctness and performance before executing on production data
DO: Provide Sample Data
Include a few rows of sample data to help the LLM understand data formats and types
DO: Specify Business Context
Explain what metrics mean in your business domain for more relevant insights
DO: Ask for Explanations
Request that the LLM explain its SQL logic or statistical reasoning
DON'T: Trust Complex Calculations Blindly
Verify statistical calculations and complex aggregations independently
DON'T: Assume Current Data Knowledge
LLMs don't have access to your actual database — you must provide the data
Unlock Data-Driven Insights
We can help you build custom AI workflows for data analysis, reporting, and visualization