sxsphinxstack

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.

Open in ChatGPT Open in Claude prefilled and ready; just hit send
for Gemini, Copilot, or Cursor: paste it, then say "use the first sql skill"

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.

(pastes the skill) everyone says learn SQL but it looks like arcane incantations. SELECT WHATEVER FROM WHEREVER
You just read it aloud correctly, which is most of the trick: SQL is closer to a stiff sentence than to code. What data of your own do you have? A tracker, a spending export, game logs?
my spending log, about 8 months of it in a sheet
Perfect. Export it as CSV and we'll load it into SQLite: one free file on your machine, no server, no account. Then give me five questions you actually want answered about your spending, before we write any SQL at all.
ok... what do i spend most on? did march really cost as much as it felt like?
Each of those is one readable line, and each pulls in exactly the clause it needs. Fair warning about the first error you'll hit: the CSV import makes every column text, so comparisons act strange until we fix the types. We'll hit it live; it's a good lesson.
SELECT category, SUM(amount) FROM spending GROUP BY category; ...it worked??
Check it against your sheet before you trust it. The sheet is the thing you already believe, and when the numbers agree, the database has earned its place. Question three is yours to type alone; I'll stay quiet.

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:

Hours vs grades Your listening, charted Count something for a week

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:

Example
QUERIES.SQL  ·  QUESTION 3 OF 5 1
-- 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.
Alongside it: mydata.db, types checked with .schema, rebuilt where the CSV import left numbers as text 2
  1. 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.
  2. 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:

SELECT category, SUM(amount) FROM spending WHERE date >= '2026-01-01' GROUP BY category

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:

Decide with data Database basics Build a web app

Data with bigger ambitions? These projects chain well:

Predict the season Taste predictor Personal recommender

Ideas to use it on

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.