For working with data yourself
6 chapters · 13 lessonsAbout 1.5 h
A free, hands-on SQL course you can run in your browser. Connect to a database that behaves just like PostgreSQL, look around, and pull out exactly the rows you need.
This course continues from Database Introduction
SQL is the language for fetching the rows you want from a database and changing its data. Whether you build apps or read numbers, it is the same language.
This course uses one small online shop database from the first lesson to the last. Reading the same tables again and again is what makes the shapes stick.
The database in the exercises is a simulation running in your browser, checked byte for byte against real PostgreSQL 17 output. Even the error messages match, so what you learn to read here reads the same at work.
Connect, see which tables exist, and read their columns and types.
Filter, sort, and limit, so you get exactly the rows you were after.
Learn the routine that lets you undo a change you did not mean to make.
Read and write the tables from Database Introduction, now with SQL you write yourself.
Connect yourself and pull out exactly the rows you need.
Try the parts people get wrong the most, NULL and joins, and see what actually happens.
6 chapters · 13 lessons
SELECT * FROM customers;psql shopSELECT stock, name FROM products;SELECT name AS product, price * stock AS retail_value FROM products;SELECT id, name, stock FROM products WHERE stock < 7;WHERE city = 'Berlin'WHERE signup_date >= '2026-03-01' AND city = 'Berlin'WHERE status IN ('paid', 'shipped')WHERE name LIKE 'K%'WHERE phone IS NULLWHERE phone IS NOT NULLWHERE city <> 'Tokyo' OR city IS NULLORDER BY price DESCORDER BY customer_id, order_date DESCORDER BY city NULLS FIRSTORDER BY stock DESC LIMIT 3ORDER BY id DESC LIMIT 2 OFFSET 6SELECT round(avg(stock), 1) FROM products;SELECT count(*), count(phone) FROM customers;WHERE status <> 'cancelled'SELECT customer_id, count(*) AS order_count FROM orders GROUP BY customer_id;GROUP BY customer_id HAVING count(*) >= 2SELECT o.id, o.customer_id, o.order_date, c.name FROM orders o JOIN customers c ON o.customer_id = c.id;SELECT c.id, c.name, count(*) AS order_count FROM customers c JOIN orders o ON o.customer_id = c.id GROUP BY c.id, c.name;JOIN orders o ON o.id = i.order_id JOIN products p ON p.id = i.product_idFROM customers c LEFT JOIN orders o ON o.customer_id = c.idWHERE o.id IS NULLSELECT c.id, c.name, count(o.id) AS order_countLEFT JOIN orders o ON o.customer_id = c.id AND o.status = 'paid'INSERT INTO products (name, price, stock) VALUES ('Cable Organizer', 12.00, 0);UPDATE products SET stock = 5 WHERE name = 'USB-C Dock';SELECT id, name, stock FROM products WHERE name = 'USB-C Dock';DELETE FROM products WHERE name = 'Cable Organizer';BEGIN;COMMIT;ROLLBACK;BEGIN; UPDATE products SET stock = 10 WHERE stock < 5;Join thousands of developers who've mastered the terminal. Your first lesson awaits.
Get Started →