Skip to main content

Interactive course

SQL Course

Learn SQL from scratch with realistic datasets and a real Postgres in your browser: write queries, inspect result sets, fix errors, and advance to CTEs, window functions, indexes, and transactions.

01 · Basic SELECT

4 lessons

The foundations: reading data from a table and filtering it.

  1. 1.1Introduction to SQLWhat SQL is, why it is used, and how a relational database is structured.~10 min
  2. 1.2SELECT … FROMThe simplest query: reading columns and rows from a table.~12 min
  3. 1.3Filtering with WHERESelect only the rows that match a condition.~14 min
  4. 1.4Sorting with ORDER BYOrder query results ascending or descending.~12 min

02 · More Powerful SELECT

4 lessons

Limit, deduplicate, rename, and summarize: the tools you use every day.

  1. 2.1Limiting with LIMITReturn only the first N rows, for example to build top-N rankings.~10 min
  2. 2.2Unique Values with DISTINCTRemove duplicate rows from a SELECT result set.~10 min
  3. 2.3Renaming with ASGive clearer column and expression aliases in your result set.~10 min
  4. 2.4Counting and Summarizing: COUNT, AVG, MAXAggregate functions: collapsing many rows into summary metrics.~12 min

03 · JOIN and GROUP BY

4 lessons

Combine multiple tables and build grouped reports: the heart of real-world SQL queries.

  1. 3.1Joining Two Tables: INNER JOINCombine matching rows across tables along primary and foreign keys.~14 min
  2. 3.2Keep Everything on the Left: LEFT JOINPreserve unmatched rows from the left table instead of dropping them.~14 min
  3. 3.3Grouping with GROUP BYCompute one aggregate row per group, such as per department.~14 min
  4. 3.4Filtering Groups: HAVINGKeep only groups whose aggregate result satisfies a condition.~12 min

04 · Practical SQL

4 lessons

Everyday tools that make the difference in production: lists, ranges, NULLs, and conditional logic.

  1. 4.1Lists and Ranges: IN and BETWEENCompact filters for matching a set of values or an inclusive range.~12 min
  2. 4.2Handling NULLs: IS NULL and COALESCEDetect missing values reliably and replace NULLs with sensible defaults.~14 min
  3. 4.3Conditional Logic: CASE WHENClassify rows and branch values directly inside SELECT.~14 min
  4. 4.4A Query Inside Another: SubqueriesUse the result of one SELECT inside another query with IN, EXISTS, or scalar values.~15 min

05 · Advanced JOINs

4 lessons

Multi-table JOINs, self-joins, OUTER JOINs, CROSS JOINs, and set operations: combine data like a pro.

  1. 5.1JOINs on Three or More TablesTraverse a chain of relationships (orders → customers → products) in one query.~15 min
  2. 5.2Self-JOIN: A Table Joined to ItselfQuery internal hierarchies by aliasing the same table in two distinct roles.~14 min
  3. 5.3OUTER JOIN: Finding the GapsUse LEFT, RIGHT, and FULL OUTER JOINs to find unmatched or missing records.~14 min
  4. 5.4UNION, INTERSECT, EXCEPT (and CROSS JOIN)Combine result sets using union, intersection, difference, and Cartesian products.~15 min

06 · Built-in Functions

4 lessons

Transform and normalize data with native PostgreSQL functions for strings, dates, numbers, and casts.

  1. 6.1String FunctionsLOWER, UPPER, LENGTH, concatenation, SUBSTRING, TRIM, REPLACE, LIKE, and ILIKE.~14 min
  2. 6.2Date and Timestamp FunctionsEXTRACT, DATE_TRUNC, intervals, and differences between timestamps.~14 min
  3. 6.3Numeric FunctionsROUND, CEIL, FLOOR, ABS, MOD, and integer vs. decimal division.~14 min
  4. 6.4CAST and Type ConversionsConvert values explicitly between types with ::type and CAST(... AS ...).~12 min

07 · Advanced Analytics

4 lessons

Multi-step queries (CTE), rankings and running totals (window functions), and arbitrary hierarchies (WITH RECURSIVE).

  1. 7.1CTEs: Multi-step Queries with WITHBreak complex queries into readable, named temporary steps.~15 min
  2. 7.2Window Functions: Rankings and Group CalculationsROW_NUMBER, RANK, and DENSE_RANK with OVER (PARTITION BY ...) without collapsing rows.~16 min
  3. 7.3LAG, LEAD, and Running TotalsCompare each row to its neighbors and accumulate cumulative totals.~15 min
  4. 7.4Recursive CTEs: Arbitrary-Depth HierarchiesUse WITH RECURSIVE to walk parent-child category and org trees of unknown depth.~16 min

08 · Writing and Modifying Data

4 lessons

INSERT, UPDATE, DELETE, CREATE TABLE with constraints, and transactions: closing the read/write loop.

  1. 8.1Inserting Data: INSERTSingle and multi-row INSERTs, explicit column lists, and RETURNING clauses.~14 min
  2. 8.2Updating and Deleting: UPDATE and DELETETargeted updates and deletes with WHERE — and how to avoid modifying whole tables.~14 min
  3. 8.3Creating Tables and Constraints: DDLCREATE TABLE with PRIMARY KEY, NOT NULL, UNIQUE, FOREIGN KEY, CHECK, and DEFAULT.~15 min
  4. 8.4Transactions: All or NothingUse BEGIN, COMMIT, and ROLLBACK to make multi-step data changes atomic.~14 min

09 · Data Structures and DDL

4 lessons

Designing schemas cleanly with advanced types, multi-column constraints, ALTER TABLE, and views.

  1. 9.1Advanced Data Types and ENUMsPrecision numeric types, TEXT vs. VARCHAR, BOOLEAN, UUID, and custom ENUM types.~14 min
  2. 9.2Composite and Table-Level ConstraintsCompound PRIMARY KEY and UNIQUE constraints, CHECK rules, and ON DELETE CASCADE.~15 min
  3. 9.3Changing Table Structure: ALTER TABLEAdd, alter, and drop columns and constraints safely on existing tables.~14 min
  4. 9.4Views and Data AbstractionUse VIEWs to encapsulate complex queries and MATERIALIZED VIEWs to cache heavy reads.~15 min

10 · Optimization and Indexes

4 lessons

Making queries fast in production: B-Tree indexes, query plans, composite/partial indexes, and eliminating N+1 queries.

  1. 10.1Indexes and B-TreesSpeed up selective lookups and joins dramatically with balanced B-Tree indexes.~16 min
  2. 10.2EXPLAIN and ANALYZERead PostgreSQL query execution plans and costs to spot bottlenecks.~16 min
  3. 10.3Composite and Partial IndexesDesign multi-column indexes (leftmost-prefix rule) and filtered partial indexes.~15 min
  4. 10.4The N+1 ProblemReplace chatty per-row ORM round-trips with a single batched SQL JOIN or CTE.~15 min

11 · Transactions and Concurrency

4 lessons

Coordinate concurrent writes safely using ACID properties, row-level locks, and isolation levels.

  1. 11.1ACID Transactions (BEGIN / COMMIT)Guarantee atomicity, consistency, isolation, and durability across multi-statement flows.~15 min
  2. 11.2Race ConditionsUnderstand read-modify-write anomalies and lost updates under concurrent transactions.~14 min
  3. 11.3Locking and SELECT FOR UPDATEAcquire exclusive row locks cleanly while reading critical state to prevent overselling.~16 min
  4. 11.4Isolation LevelsChoose between Read Committed, Repeatable Read, and Serializable tradeoffs.~15 min

12 · Functions and Triggers

4 lessons

Encapsulate reusable business rules inside PostgreSQL with SQL functions, PL/pgSQL blocks, and event triggers.

  1. 12.1UDFs and SQL FunctionsCreate reusable SQL User Defined Functions directly inside the database.~15 min
  2. 12.2Procedural Logic with PL/pgSQLUse variables, IF/ELSE branches, loops, and RAISE exceptions inside stored functions.~16 min
  3. 12.3Introduction to TriggersInspect incoming NEW and outgoing OLD rows with BEFORE and AFTER trigger functions.~16 min
  4. 12.4Practical Triggers and Audit LogsAutomate updated_at timestamps and record tamper-evident DELETE audit trails.~16 min

13 · Window Functions

4 lessons

Deep analytical queries without losing row granularity: OVER(), PARTITION BY, frames, rankings, and LAG/LEAD.

  1. 13.1Introduction and the OVER ClauseRun aggregate calculations alongside individual detail rows using OVER().~15 min
  2. 13.2Partitioning with PARTITION BYSplit rows into independent analytical windows without collapsing them like GROUP BY.~15 min
  3. 13.3Rankings: ROW_NUMBER, RANK, and DENSE_RANKAssign row numbers and leaderboard ranks with predictable tie-breaking.~16 min
  4. 13.4Row Offsets: LAG and LEADCompare current rows against preceding or following rows to compute deltas and trends.~15 min

14 · CTEs and Hierarchical Queries (WITH)

3 lessons

Replace tangled subqueries with modular Common Table Expressions and walk graph/tree structures recursively.

  1. 14.1Introduction to CTEs (WITH)Factor out temporary named result sets cleanly at the top of a query.~14 min
  2. 14.2Multiple and Chained CTEsBuild readable multi-stage analytical pipelines inside a single WITH clause.~16 min
  3. 14.3Recursive CTEs: Tree DataTraverse org charts and category trees with an anchor term and recursive UNION ALL step.~18 min

15 · PostgreSQL JSON and NoSQL

2 lessons

Combine relational integrity with flexible document storage using native JSON, JSONB operators, and JSON aggregation.

  1. 15.1JSON and JSONB IntegrationStore semi-structured documents in columns and query nested keys with ->, ->>, and @>.~15 min
  2. 15.2JSON Aggregation FunctionsBuild structured JSON objects and arrays natively in SQL with json_build_object() and json_agg().~15 min
Frequently asked questions

SQL Course FAQ

How many lessons and hands-on exercises are in SQL Course?

SQL Course covers 15 modules, 57 interactive lessons, and 288 practical exercises (~14 hours total) with instant automated validation.

Do I need local setup or IDE installation for SQL Course?

No installation required: every exercise and the interactive SQL Course playground execute right in your browser via WASM and isolated sandboxes, with instant feedback.

Is Module 1 of SQL Course free without creating an account?

Yes. Module 1 (“Module 1 — Basic SELECT”), the live playground, and the printable cheatsheet are permanently free without signup, saving your progress locally in your browser.

Which career learning paths include SQL Course?

SQL Course is a core building block of AI Engineering & Machine Learning, Data, SQL & Analytics, Backend, Systems & DevOps, Application Security & AppSec, targeting roles such as AI Engineer · ML Engineer · LLM Systems Engineer · Data Analyst · Analytics Engineer · BI Developer · Backend Engineer · Systems / SRE · Platform Engineer · Application Security Engineer · Security-First Full-Stack.