Skip to content
  • Official
  • Beginner
  • English
  • About 70 min
  • 9 steps · 2 quizzes

SQL from Zero — Ask Questions of Your Data

A hands-on first lesson in SQL, the language for asking questions of data. Students query a small table of songs right inside the lesson…

  • Free
  • No account needed
  • Stop any time, pick up where you left off
Workshopy.io

WorkshopyOfficial

28 lessons · used by 2 teachers

For teachers

Teaching this? Run it live with your class.

  • Students join with a code — no accounts
  • See who’s done and who’s stuck, step by step
  • It’s your copy — change anything before class

Sign in to copy it to your workspace. It’s free.

Your path

9 steps · 2 quizzes · about 70 minutes · open any step

  1. A table: rows and columnsStart hereData in a database lives in tables. A table looks like a spreadsheet: each row is one thing — here, one song; each column is one fact about every thing — its title, its year, its plays. Try it: tap a few cells, then press Run.InteractiveHands-on · 6 min
  2. SELECT: choose the columnsSELECT lists the columns you want, separated by commas. means all of them. Try it: tap column names to build the query and watch the other columns fade away. Then press rename with AS: title AS song gives a column a new name in the result.InteractiveHands-on · 6 min
  3. WHERE: keep only some rowsWHERE tests every row against a condition and keeps the rows where it's true. Text goes in single quotes: genre = 'Pop'. Numbers don't: year >= 2022. Compare with =, !=, <, >, <= and >=. Try it: run the examples.InteractiveHands-on · 6 min
  4. AND, OR, NOT and LIKECombine conditions: AND — both must be true. OR — at least one. NOT — flips it. LIKE matches a pattern: % is any text, is exactly one character. title LIKE '%love%' finds "love" anywhere in the title.InteractiveHands-on · 6 min
  5. ORDER BY and LIMIT: a top 5ORDER BY sorts the result: ASC smallest first (the default), DESC largest first. Sort by several columns with commas. LIMIT 5 keeps only the first 5 rows. Together they answer "top N" questions.InteractiveHands-on · 6 min
  6. Check: choose, filter, sortQuiz · 5 questions
  7. Aggregates: one answer from many rowsSometimes you want one number about many rowsInteractiveHands-on · 6 min
  8. GROUP BY: one row per groupGROUP BY genre sorts the rows into a pile per genre, and the aggregate runs once per pile: SELECT genre, COUNT() FROM songs GROUP BY genre; The rule: every column in SELECT must be in GROUP BY or inside an aggregate.InteractiveHands-on · 6 min
  9. Challenge: 5 questionsAnswer each question with a query. A ✓ appears when your result is right — the order and names of the columns don't matter.InteractiveHands-on · 6 min
  10. What's next: joining tablesReal databases split data into several tables — songs in one, artists in another — so each fact is stored only once. JOIN connects them through a shared column. Try it: press Connect, then Join.InteractiveHands-on · 6 min

Comments 0

You’ll sign in with Google before it’s posted.Comments are public — don’t name your students.
0 / 1,500

No comments yet. Be the first to say how it went.

Using it

Workshopy shares this lesson under CC BY 4.0. Anyone may use and change it, with credit to you. Anyone can learn it here, free. A copy in your workspace is yours to change and run live; your students never need an account.

Versions

  1. 1

    Version 1Current

    · First published

Copies are made from the current version. A copy you already have doesn’t change.

More from Workshopy

All 28 lessons