Help

How to get Gemini to write SQL for you, what to do when its answer and your hand card disagree, and the one rule for every AI tool.

Get Gemini to write SQL from your steps

SQL is a short language for asking a table a question. One question in SQL is called a query. You do not write SQL from an empty page. You write the steps, Gemini writes the SQL, and you check the result.

  1. Work the steps by hand first, on your hand card. Without your own numbers, you have nothing to check the AI against.
  2. On the Practice page, fill in the five boxes: Goal, Data, Steps, Rules and Check first. The page adds the table names and their columns for you.
  3. Press Copy prompt. Open Gemini and paste the prompt.
  4. Copy only the SQL from Gemini's answer. It usually sits in a grey box that starts with SELECT or WITH.
  5. Paste it into the query box on the Practice page and press Run.
  6. Compare the Check first rows with your hand card, line by line. Only when every line matches, ask for the whole table.

Here is a prompt in the course's five parts. It works out revenue for session 2's demo card first:

Goal: work out revenue for the table course.lines_raw.
Data: course.lines_raw. Each row is one invoice line.
Steps: 1. Revenue is Quantity times Price.
2. Count the lines. 3. Add up Revenue.
Rules: Keep every line, including lines with a minus Quantity.
Check first: Do the steps only on the rows labelled 592949 to
592960, both included. Print each line with its Revenue.

Why name both end rows? Code often stops one row early. And why print each line? A wrong total then points at the line that went wrong.

When the SQL does not run

The Practice page says what went wrong in plain words. Under that, Technical details holds the exact message. Copy it into Gemini and ask it to fix that one problem. Do not ask it to start again.

The practice warehouse reads SQL written the BigQuery way, as Gemini writes it, so the same query works in the class notebook. A few rare BigQuery functions are not known here. When that happens, the page tells you, and Gemini can write that step another way.

When the AI and your hand card disagree

This is the mismatch protocol from session 2. Do not reword the prompt and hope. Take these six steps, in order:

  1. Recheck your own arithmetic. Your card can be wrong too.
  2. Ask the AI to print each card line, with its kind and its revenue.
  3. Find the first line that differs. Compare row by row, not just the totals.
  4. Name the rule that line broke. Which step removed it, or counted it wrongly?
  5. Fix that one step in the prompt. Add or change one sentence, not the whole prompt.
  6. Run the match again. If a line still differs, go back to step 3. When every line matches, run it on the whole table and count the lines.

Rewording the whole prompt until the number agrees is not a step. A match by luck fixes nothing you understand. A real AI mistake that you catch and explain earns full marks for that part of your coursework.

Paste nothing personal into any AI tool

Use course data only. Never paste names, email addresses, phone numbers, customer lists from your work, or anything else about a real person into Gemini or any other AI tool.

Why: Google may keep what you type into Colab's AI, with the code and the output, for up to 18 months, and human reviewers may read it.

The course rule, the same in every brief:

You may use Gemini in Colab in labs and coursework, but every number you submit must match your own hand card and a cell that ran. Hand cards, the privacy audit and the oral defence are done without AI, with phones in bags. Paste nothing personal into any AI tool.

When Gemini does not answer

First use your partner's account. Then use the Gemini web app, gemini.google.com, in a side window. If both fail, work on paper with your partner. Each lab also has a backup notebook with Gemini's code already written in.

Words used on this site

Hand card
A small slice of the data, five to twelve rows, that you work by hand before you trust the AI.
Prompt
The message you type to an AI assistant such as Gemini.
SQL and query
SQL is a short language for asking a table a question. One question in SQL is a query.
Table, row and column
A table is data in rows and columns. In the course table, one row is one invoice line, and a column holds one kind of value, such as Price.
Notebook
A web page of small boxes of code, called cells, that you run one at a time in Google Colab.
BigQuery
Google's tool for asking very large tables questions in SQL. The course's tables course.lines_raw and course.sales live there.
Scan
How much data BigQuery reads to answer a query. It reads whole columns, so a query that names fewer columns reads less.
CSV file
A plain table file. Excel and Google Sheets open it.
Mismatch protocol
The six steps you take when your hand card and the AI disagree.

Still stuck?

Ask your instructor before or after any session, or ask on the course's hand-in site, rsu.marxp.com. A question asked early saves a lost mark later.