Ask for SQL you can check

Módulo 1: Analyze with AI, and catch its mistakes

Conteúdo do curso

Esta aula ainda não está no seu idioma, então aqui está em inglês.

Teste rápido

Guess first, no penalty. You ask an AI: "Write SQL for revenue by country." What will it have to guess?

A prompt is the message you send to the AI. A schema is the list of your tables and their columns. Without them, the AI invents plausible names and picks its own definitions.

A SQL prompt you can check has four parts:

  • Tables: names, key columns and how they join.
  • Definitions: what "revenue" or "active customer" means at your company.
  • Rules: the date range, the time zone, and what to leave out, like refunds or test accounts.
  • Return: the query, every assumption it made, and a second query that counts the rows.

The assumptions list is the part you'll use most. It shows you exactly where the model guessed.

A worked example

Write a PostgreSQL query for monthly revenue by country.

Tables: orders(order_id, customer_id, amount_usd, status, created_at),
customers(customer_id, country). Join on customer_id.

Definitions: revenue = sum of amount_usd where status = 'paid'.

Rules: created_at is in UTC. Use 1 Jan to 30 Sep 2026.
Leave out customers whose email ends in @test.example.

Return: the query, a list of every assumption you made, and a query
that counts the orders included so I can check the result.

Preencha as lacunas

Fill the gaps.

Prompt

Tables: . Definitions: revenue = . Return: the query and .

Your turn:

Write a [dialect] query for [question].
Tables: [names, key columns, how they join]
Definitions: [metric] = [exact rule]
Rules: [date range], [time zone], [what to leave out]
Return: the query, every assumption, and a row-count query.

Try it

Seus passos, cerca de 2 minutos

0 de 1
  1. 1.Write the prompt for one question you answer every month, run it, and mark any assumption you'd change. Add "read the assumptions list" to your checklist.2 min

Exercícios

Pergunta 1 de 2

Your AI-written revenue query includes refunded orders, and the total is higher than finance's. Which part of the prompt was missing?

Tutor de IA

Tire dúvidas sobre esta aula e tenha ajuda na tarefa do “Experimente”. O tutor faz parte do Learn Pro.

Ver o Learn Pro