Mission 09 / 20 AI-Assisted SQL & Analysis
0 / 20 complete
Rookie Analyst 0 XP
+100 XP Mission complete.
AI-Native Analytics · Module 09

AI-Assisted SQL & Analysis.

Use AI to compress the mechanical parts of analysis without outsourcing the question, metric definition or judgment.

Core idea

The quality of AI analysis depends less on a clever prompt than on the quality of the analytical context you provide.

01
Context

The AI wrote 90 lines of SQL in seconds.

CompanyQuickCartRequestWhy did orders fall?AI output90-line queryProblemLooks plausible, context is missing
“The query runs and the numbers look reasonable. Can we send the conclusion to leadership?”

Fast syntax generation is useful, but an AI system does not automatically know your metric contracts, grain, exclusions, late-arriving data rules or business decision.

A strong workflow gives AI a structured analytical brief first, then treats generated SQL as a draft that must earn trust.

02
Context bundle

Give the model the same context a good analyst would ask for.

01

Decision

What decision should this analysis improve?

02

Definitions

Provide metric contracts, exclusions and time logic.

03

Data model

State table grain, keys, relationships and known caveats.

04

Output contract

Specify the required grain, comparisons and validation checks.

Rule

Do not ask AI to “analyze the data” when you have not defined what a correct answer would look like.

03
Challenge

Turn a weak AI request into an analytical specification.

Exercise · 15–25 minutes

Rewrite the prompt.

  1. What decision is the stakeholder making?
  2. What metric definitions must be provided?
  3. What table grain and join risks should be stated?
  4. What output grain should the answer use?
  5. Which control queries should the AI provide?
  6. What conclusions should the AI explicitly avoid making?
04
AI assist

Ask for reasoning structure before code.

Strong analysis request
Business question:
Explain the week-over-week decline in completed orders.

Decision:
Determine which area should be investigated first; do not recommend spend changes yet.

Metric contracts:
- completed_order = distinct eligible order_id with final status completed
- reporting week = created_at week
- cancellation_rate = cancelled eligible orders / placed eligible orders

Data model:
orders = one row per order
customers = one row per customer
status_events = many rows per order

Before SQL:
1. Restate the question and required output grain.
2. Identify ambiguities and join risks.
3. Propose the analysis plan.
4. Write SQL in testable layers.
5. Provide control queries.
6. Separate observed findings from causal claims.
05
Validation

The AI-assisted analysis checklist.

01

Did the prompt include the decision, not only the metric?

02

Were metric definitions and time attribution explicit?

03

Did the model state the expected grain before joining?

04

Did it identify unknowns rather than invent them?

05

Can each major number be reconciled to a simpler control?

06

Does the final language distinguish observation from cause?

06
Worked takeaway

AI should reduce typing, not analytical ownership.

Before AI

Frame the decision and write metric definitions.

During AI

Provide schema context and request an explicit plan.

After AI

Validate SQL, totals, edge cases and conclusions.

Final output

Keep only claims supported by checked evidence.

Analyst habit

Treat AI-generated analysis like work from a very fast junior analyst: useful, inspectable, and never exempt from review.