Skills / First SQL
First SQL
Teach first SQL on the person's own data. A CSV into SQLite, then real questions answered with SELECT, WHERE, and GROUP BY. Use when they say "teach me SQL", "what's a database", or their spreadsheet questions have outgrown formulas.
Use this skill. Nothing to install.
Don't have an agent? · Raw file: skills/first-sql.md
Watch the first two minutes
This is how a first SQL session starts, intimidation included. Click through it.
Scripted example of a real session.
Doesn't SQL need a server and a CS degree?
Neither. The tool is SQLite: the whole database is a single file in a folder you
own, and the sqlite3 program is already on most machines (there's a free
GUI, DB Browser for SQLite, if you'd rather click). The degree gets replaced by your
own curiosity: the session collects five real questions about your data first, and
syntax arrives as a side effect of answering them. WHERE turns out to be the filter
button, GROUP BY turns out to be the pivot table, and both were already yours. Data
worth querying is the only prerequisite; these projects generate plenty:
What you end up with
A database built from your own CSV, and a queries.sql file where every
question keeps its query and its answer. An excerpt:
-- Q3: Which month did food actually cost the most?
SELECT strftime('%Y-%m', date) AS month,
SUM(amount) AS food_total
FROM spending
WHERE category = 'food'
GROUP BY month
ORDER BY food_total DESC
LIMIT 3;
month food_total
------- ----------
2026-03 164.20
2026-01 131.75
2026-04 118.40
-- Answer: March, by about $32. The camping trip
-- groceries, mostly. Matches the sheet's SUMIF.
- Question, query, answer, together. The comment holds the question in plain words, AS gives result columns honest names, and the noted answer makes the file both a reference and a proof. When the data grows, every query reruns.
- Verified against the sheet. March's total agrees with the spreadsheet's SUMIF, which is how the database earns trust. The session ends with you answering a brand-new question end to end, unassisted.
Anatomy of your first real query
Every clause maps to something you already do in a sheet:
- A What you want back. COUNT and SUM answer "how many" and "how much".
- B The table, which was your sheet's tab five minutes ago.
- C The filter, doing the same job as the filter button in a sheet.
- D Per-category totals: the pivot table's job in one readable clause.
Questions people actually ask
Do I need to install anything?
Usually not. sqlite3 ships with macOS and most Linux systems, and the
agent checks yours first. If you prefer a GUI, DB Browser for SQLite is a free
download.
I don't have any data. Can I use sample data?
The skill will stop and route you to track-anything or spreadsheet-basics first. SQL on synthetic rows teaches syntax and nothing else; the whole method depends on you caring about the answers.
Do I need to know programming first?
No. SQL here is a question language: you describe what you want and the database fetches it. Nothing in the session assumes you have written code before.
What happens when my query errors?
You read the error together with the agent. SQLite's messages are better than their reputation and usually point at the exact word to fix. Wrong-looking results get checked against your sheet, which stays the source of trust.
My spreadsheet already answers these questions. Why bother?
At small size, the sheet is fine and the skill says so. The win shows up as questions get sharper: "top category per month" is a short readable query, while the sheet version becomes a formula buried in a cell that even you can't re-explain in a month.
Where to go from here
Five questions answered? The next skills up:
Data with bigger ambitions? These projects chain well:
Ideas to use it on
- Predict the season — Can you predict how your team's remaining games go, and prove you called it before kickoff?
Curious? Read the full skill — the exact instructions your agent gets
---
name: first-sql
category: data
description: Teach first SQL on the person's own data. A CSV into SQLite, then real questions answered with SELECT, WHERE, and GROUP BY. Use when they say "teach me SQL", "what's a database", or their spreadsheet questions have outgrown formulas.
---
# first-sql
Teach someone their first SQL, and the database is their
own data: the tracker sheet, the cleaned dataset, their game logs or
spending export, saved as CSV. SQLite is the tool: a single local file with no
server. Detect whether the `sqlite3` CLI or DB Browser for SQLite is available
before choosing the instructions; install only with the person's permission.
Every query in this
session answers a question they actually have; syntax is learned as
a side effect of getting answers.
## Import their data
Export their sheet as CSV. If they have no data worth querying, stop
and do track-anything or spreadsheet-basics first — SQL on synthetic
rows teaches syntax and nothing else. Then, in a folder they own:
Keep the original CSV unchanged. Remove or mask names, bank details, contact
information, and other identifiers that the questions do not need before import.
sqlite3 mydata.db
.mode csv
.import data.csv log
.mode table
SELECT * FROM log LIMIT 5;
Explain the shape shift: the sheet's tab is now a table, rows are
rows, columns are columns, and the file `mydata.db` is the whole
database. Check types with `.schema` — CSV import makes everything
text, so numbers may need a rebuild with proper column types or a
CAST when comparing. Hit this problem live; it is the same lesson as
typed columns in clean-a-dataset.
## Questions, then clauses
Collect five real questions about their data before writing any SQL,
then let each question pull in its clause:
1. "Show me the recent ones" — SELECT columns, ORDER BY date DESC,
LIMIT.
2. "Just the ones where..." — WHERE with =, >, LIKE; AND/OR for
compound filters.
3. "How many? How much in total?" — COUNT(*), SUM, AVG, MIN, MAX.
4. "...per category / per month?" — GROUP BY, and aliases (AS) so
result columns have honest names. Per-month needs
strftime('%Y-%m', date), a nice moment for why date typing
mattered.
5. "Which groups matter?" — HAVING to filter the groups, ORDER BY
on the aggregate to rank them.
They type every query. When one errors, read the error together —
SQL error messages are better than their reputation. When a result
looks wrong, check it against the sheet: the sheet is the thing they
trust, and agreement is how the database earns trust. Compare with
the spreadsheet way as you go: WHERE is filter, GROUP BY is the
pivot table, and the win is that a question is one readable line
instead of a formula buried in a cell.
## Keep the answers
Make a `queries.sql` file: each of the five questions as a comment,
its query underneath, and the answer noted. This is their reference
and their proof — rerunnable when the data grows. Finish by having
them answer one brand-new question alone, from question to result,
while you watch and stay quiet.
## Done
- `mydata.db` built from their real CSV, types checked
- Five real questions answered with queries they typed, covering
WHERE, GROUP BY, and an aggregate
- `queries.sql` saved with questions, queries, and answers
- One unassisted question answered end to end
Then: decide-with-data to put numbers under a real decision, or
build-web-app if this data deserves an app around it.








