Learn SQL by actually running it

Learn SQL by writing real queries, not by watching videos. SQLearn gives you 8 short lessons, 40 hands-on exercises that check your answers instantly, quizzes that play like boss battles, and a free playground. It all runs on a real SQLite database inside your browser. Free, no account, nothing to install.

The SQL curriculum

  1. SELECT: Ask the Oven. Pull data out of a table. The one command you will type a million times. (4 exercises, 5-question quiz)
  2. WHERE: The Picky Eater. Filter rows so you only get the ones you actually care about. (6 exercises, 6-question quiz)
  3. ORDER BY & LIMIT: Top Charts. Sort your results and grab just the top few. (5 exercises, 5-question quiz)
  4. Aggregates: Crunch the Numbers. COUNT, SUM, AVG, MIN, MAX. Squash many rows into one answer. (5 exercises, 5-question quiz)
  5. GROUP BY: Sort Into Buckets. One aggregate per group. This is the report-building superpower. (5 exercises, 5-question quiz)
  6. JOINs: Connect the Tables. Orders know a customer_id. Customers know names. JOIN puts them in one row. (5 exercises, 6-question quiz)
  7. Subqueries & CASE: Queries Inside Queries. Nest one query in another, and teach SQL to make decisions. (5 exercises, 5-question quiz)
  8. INSERT, UPDATE, DELETE: Change the World. Reading is fun. Writing is power. Use responsibly. (5 exercises, 5-question quiz)

How SQLearn works

  • Real database in your browser: SQLite compiled to WebAssembly. Every query you type actually runs.
  • Auto-graded exercises: your result set is compared with the reference, so any correct query passes, and the feedback says exactly what differs.
  • Boss battles: timed quizzes with concept, predict-the-output, fix-the-bug and write-the-query questions.
  • Progress that sticks: XP, levels, badges and streaks saved in your browser. No account needed.

The practice database: Pixel Pizzeria

pizzas

  • id (INTEGER), primary key
  • name (TEXT)
  • category (TEXT), Classic / Wild / Gourmet / Deep Dish / Vegan
  • price (REAL)
  • calories (INTEGER)
  • is_vegetarian (INTEGER), 1 = yes, 0 = no
  • chef_id (INTEGER), → chefs.id

customers

  • id (INTEGER), primary key
  • name (TEXT)
  • city (TEXT)
  • favorite_topping (TEXT), can be NULL
  • loyalty_points (INTEGER)
  • joined_on (TEXT), YYYY-MM-DD

orders

  • id (INTEGER), primary key
  • customer_id (INTEGER), → customers.id
  • pizza_id (INTEGER), → pizzas.id
  • quantity (INTEGER)
  • ordered_at (TEXT)
  • delivered (INTEGER), 1 = yes, 0 = no

chefs

  • id (INTEGER), primary key
  • name (TEXT)
  • specialty (TEXT)
  • years_experience (INTEGER)
  • hourly_wage (REAL)

Frequently asked questions about learning SQL

What is the best way to learn SQL for free?

Write real queries and get told right away whether they worked. Reading about SQL is easy to forget; typing a SELECT, seeing the rows come back, and fixing it when it fails is what makes it stick. SQLearn is built around that loop: 8 short lessons, 40 exercises that grade themselves, quizzes at the end of each topic, and a playground where you can try anything. It runs a real SQLite database in your browser, so there is nothing to install and no account to create.

How long does it take to learn SQL basics?

For most people, a solid grasp of the core (SELECT, WHERE, ORDER BY, aggregate functions, GROUP BY and JOINs) takes somewhere between 3 and 5 hours of actual practice. SQLearn splits that into 8 topics of about 20 to 30 minutes each. You can get through the fundamentals in one afternoon, or do a topic a day for a week.

Do I need to install anything to practice SQL?

No. SQLearn uses SQLite compiled to WebAssembly, which means a complete database engine runs inside the browser tab. Every query you type executes for real. If you delete a table by accident, one click resets the database and you carry on. Nothing touches your computer and you never have to sign up.

Which SQL topics does SQLearn cover?

SELECT and aliases; WHERE with AND, OR, IN, BETWEEN, LIKE and how NULL really behaves; ORDER BY, LIMIT and OFFSET; COUNT, SUM, AVG, MIN and MAX; GROUP BY and HAVING; INNER and LEFT JOINs across several tables; scalar and IN subqueries plus CASE expressions; and finally INSERT, UPDATE and DELETE. Each topic ends with a timed quiz we call a boss battle.

Is SQLearn useful for data analysts and people starting in data science?

Yes, and that was the point. The exercises are shaped like the questions analysts actually get asked: revenue per product, customers who have never ordered, the top 3 of something, a breakdown by category. Once you can answer those on the pizzeria database you can answer them on a company database.

Which SQL dialect does SQLearn use?

SQLite. For everything taught here (SELECT, JOIN, GROUP BY, subqueries, CASE, INSERT, UPDATE, DELETE) the syntax is the same as PostgreSQL, MySQL and SQL Server, so the skills carry over directly to whatever database you end up using at work.

How are the SQL exercises graded?

Your query and the reference answer both run on a fresh copy of the database, and the two result sets are compared. So any correct query passes, whether or not it looks like ours. When something is off, the feedback says exactly what: wrong number of columns, wrong number of rows, right rows in the wrong order, or a column that needs renaming. You also see your output next to the expected output.

What makes the quizzes different from a normal SQL test?

Each topic ends in a boss battle: a timed set of questions where correct answers hit the boss and misses hit you. There are four kinds of question. Some check a concept, some show you a query and ask what it returns, some hand you broken SQL to fix, and some ask you to write a query from scratch. Get three in a row and you build a combo. It is a lot more fun than a multiple choice form, and you remember more.