SQL
From your first SELECT to JOINs, window functions and indexes, on a real database running in your browser: students, courses and enrollments. Run and change every example, then finish with an analytics project for a learning platform.
Every chapter is an island. Finish its lessons, beat its challenge, and sail on ⛵
Island 1
First questions to the data
- What are SQL and databases?Tables, rows and columns, and your first query.7 min2 🎮
- SELECT: choosing columnsSpecific columns, new names with AS, calculations, and DISTINCT.8 min3 🎮
- WHERE: filtering rowsComparisons, AND/OR, IN, BETWEEN, LIKE, and the NULL trap.10 min3 🎮
- ORDER BY and LIMIT: sort and take the topSorting by several columns, where NULLs go, and paging with OFFSET.9 min2 🎮
Island 2
Summarizing and grouping
- Aggregates: COUNT, SUM, AVGTurn a whole table into one number, and mind the NULLs.8 min3 🎮
- GROUP BY and HAVINGOne number per group, and filtering the groups themselves.10 min2 🎮
- CASE, COALESCE and text functionsAn if inside a query, a fallback for NULL, and shaping text and numbers.9 min2 🎮
Island 3
Joining tables
- Keys and relationshipsPrimary and foreign keys, one-to-many and many-to-many.8 min2 🎮
- INNER JOINCombine rows from two tables where they match.9 min3 🎮
- LEFT JOIN: leave nobody outKeep every row of the first table and find what has no match.9 min2 🎮
- Three-table joins and self joinsFrom the junction table to the details, and students with their mentors.9 min2 🎮
- Subqueries and CTEsA query inside a query, and WITH to break a problem into steps.11 min2 🎮
Island 4
Building tables and changing data
- CREATE TABLE and constraintsTypes, NOT NULL, UNIQUE, CHECK and DEFAULT: a database that protects itself.10 min2 🎮
- INSERT, UPDATE and DELETEAdd, change and remove rows, without wiping the table by accident.10 min2 🎮
- Transactions: all or nothingBEGIN, COMMIT, ROLLBACK, and what ACID means.9 min2 🎮
- SQL injection: the most dangerous mistakeHow user-typed text can hijack your query, and the one right fix.8 min2 🎮
Island 5
Professional level
- Indexes: why is my query slow?How the database searches, EXPLAIN, and when an index hurts.11 min1 🎮
- Window functions: rankings and totals without losing rowsROW_NUMBER, RANK, PARTITION BY and running totals.12 min2 🎮
- Designing tables: normalizationWhy one big table goes wrong, and 1NF, 2NF and 3NF without the jargon.10 min2 🎮
- Project: analytics for a learning platformRevenue per course, completion rates and a leaderboard, using everything you've learned.15 min3 🎮