SQL for Beginners
Software Development · Beginner · 24 lessons · 6h 10m · Free
By LearnSpace Official
About this course
Learn to query, combine and change data in relational databases, from your first SELECT to window functions
A free, hands-on SQL course for complete beginners. Every lesson uses the same small online shop database (customers, orders, order items and products), so you can see exactly what each query returns and why. You will start with what a relational database is and how tables, rows and keys fit together, then write queries with SELECT, WHERE, ORDER BY and LIMIT, and learn how NULL really behaves. You will summarise data with aggregate functions, GROUP BY and HAVING, and combine tables with inner, left and self joins using a clear mental model of how rows are matched. Later sections cover subqueries, common table expressions (CTEs), CASE expressions, string and date functions, window functions such as ROW_NUMBER and running totals, and changing data safely with INSERT, UPDATE, DELETE and transactions. The course ends with CREATE TABLE and constraints, the basics of indexes, reading a query plan at a high level, and habits that keep queries correct and fast. All examples are standard SQL that runs on PostgreSQL, with notes wherever MySQL, SQLite or SQL Server do things differently.
From LearnSpace Official: https://learnspace.io
Course content
Databases and your first queries
What a relational database is, how tables, rows and keys fit together in the sample online shop, and how to choose columns, filter rows, sort results and return the top N with SELECT, WHERE, ORDER BY and LIMIT.
- What a relational database is (12m)
Most of the world’s business data lives in relational databases, and SQL is how you ask them questions. Learn what a relational database is, why it beats a pile of spreadsheets…
- Tables, rows and keys (14m)
Meet the four tables of the sample shop and the keys that connect them. Learn what columns, data types, primary keys and foreign keys are, and how one-to-many and many-to-many…
- Choosing columns and filtering rows: SELECT and WHERE (16m)
SELECT decides which columns you see and WHERE decides which rows. Learn to pick and rename columns, calculate new ones, and filter with comparisons, AND, OR, NOT, IN, BETWEEN…
- Sorting and limiting results (13m)
Results have no order until you ask for one. Learn ORDER BY with several sort keys, LIMIT and OFFSET for top-N lists and pages, DISTINCT for unique values, and how SQL Server and…
- What a relational database is (12m)
Databases and your first queries quiz Quiz
NULLs and summarising data
How missing values (NULL) behave in comparisons, filters and sorting, then how to summarise data with COUNT, SUM, AVG, MIN and MAX, split it into groups with GROUP BY, filter groups with HAVING, and the logical order in which a query runs.
- Working with NULL (15m)
NULL means "no value here", and it does not behave like zero, an empty string or any other value. Learn how comparisons with NULL work, how to test for it, how to replace it, and…
- Aggregate functions: COUNT, SUM, AVG, MIN and MAX (14m)
Aggregate functions turn many rows into one number: how many, how much in total, the average, the smallest and the largest. Learn the five core aggregates, the three kinds of…
- Grouping rows with GROUP BY (15m)
GROUP BY splits rows into groups and runs your aggregates once per group, which is how you get "orders per status" or "revenue per order". Learn how grouping works, the one rule…
- HAVING and the order a query runs in (14m)
HAVING filters groups after they are aggregated, while WHERE filters rows before. Learn when to use each, and the logical order in which the clauses of a SELECT run, which…
- Working with NULL (15m)
NULLs and summarising data quiz Quiz
Joining tables
How joins combine rows from several tables, with a simple mental model (pair every row, keep the matches). Inner joins, left joins and finding missing matches, chains of joins and self joins, and the pitfalls that produce too many or too few rows.
- How joins work (16m)
A join combines rows from two tables into one result by pairing them up. Learn the mental model that makes every join predictable: SQL considers every pair of rows and keeps the…
- LEFT JOIN: keeping rows without a match (17m)
A LEFT JOIN keeps every row from the left table, filling the right side with NULL when nothing matches. Learn how to use it to list everything, find missing records, and avoid…
- Joining several tables, and joining a table to itself (17m)
Real questions usually cross three or four tables. Learn to chain joins along the keys of the sample shop, combine joins with GROUP BY, and join a table to itself to follow…
- Join pitfalls and practice (20m)
Most wrong join results come from a handful of causes: fan-out that multiplies rows, missing or wrong ON conditions, and inner joins that drop rows. Learn to spot and fix each…
- How joins work (16m)
Joining tables quiz Quiz
Subqueries, CTEs and CASE
Answer questions that need more than one step: subqueries in WHERE, SELECT and FROM, common table expressions that name each step, CASE expressions for labels, bands and conditional counts, and the string and date functions you need for real reports, with notes on how each database differs.
- Subqueries: queries inside queries (16m)
A subquery is a complete SELECT placed inside another statement, so one question can use the answer to another. Learn scalar subqueries, IN and EXISTS, correlated subqueries and…
- Common table expressions (WITH) (15m)
A common table expression names an intermediate result at the top of a query so the rest of the query can use it like a table. Learn to write WITH queries, chain several steps…
- CASE expressions: if-then logic in SQL (14m)
CASE lets a query choose a value row by row, the way IF does in a spreadsheet. Learn the two forms of CASE, how to group values into bands, how to count several conditions in one…
- String and date functions (16m)
Cleaning up text and working with dates are everyday SQL tasks, and they are where database products differ the most. Learn the core string functions, how to extract parts of…
- Subqueries: queries inside queries (16m)
Subqueries, CTEs and CASE quiz Quiz
Window functions and changing data
Rank rows, number them within groups and calculate running totals with window functions, then learn to change data safely with INSERT, UPDATE and DELETE and to group changes into transactions that succeed or fail as a whole.
- Window functions: ranking rows without losing them (16m)
Window functions calculate across a group of related rows while keeping every row in the result. Learn how OVER and PARTITION BY work, and how to number and rank rows with…
- Running totals, moving averages and comparing rows (15m)
Add ORDER BY to a window and SUM becomes a running total. Learn running totals overall and per group, what a window frame is, how LAG and LEAD compare a row with its neighbours…
- Changing data: INSERT, UPDATE and DELETE (17m)
Reading data is safe; changing it is not. Learn how to add rows with INSERT, change them with UPDATE and remove them with DELETE, how RETURNING shows you what changed, and the…
- Transactions: all or nothing (15m)
A transaction groups several statements so they succeed or fail together. Learn BEGIN, COMMIT and ROLLBACK, what ACID means in plain words, what happens when a statement fails…
- Window functions: ranking rows without losing them (16m)
Window functions and changing data quiz Quiz
Designing tables and writing good queries
Create your own tables with sensible data types, protect your data with constraints, speed up lookups with indexes, read a query plan at a high level, and finish with the habits that keep SQL correct, readable and fast.
- Creating tables and choosing data types (16m)
So far you have queried tables someone else designed. Learn how to create your own with CREATE TABLE, how to pick sensible data types for money, text, dates and ids, and how to…
- Constraints: rules that protect your data (16m)
Constraints are rules the database enforces on every insert and update, so bad data is stopped at the door instead of cleaned up later. Learn PRIMARY KEY, FOREIGN KEY, UNIQUE…
- Indexes: making lookups fast (15m)
An index lets the database find rows without reading the whole table, the way a book index saves you reading every page. Learn what an index is, when one helps, how to create…
- Query plans and good SQL habits (16m)
EXPLAIN shows how the database intends to run your query, which is the first step in understanding why a query is slow. Learn to read a plan at a high level, then finish the…
- Creating tables and choosing data types (16m)
Designing tables and performance quiz Quiz
Frequently asked questions
How much does SQL for Beginners cost?
SQL for Beginners is free. Sign up for a free LearnSpace account to enroll and track your progress.
How long is SQL for Beginners?
24 lessons, about 6h 10m in total. It's self-paced and online, so you can start and stop whenever you like.
What does SQL for Beginners cover?
12 parts: Databases and your first queries; Databases and your first queries quiz; NULLs and summarising data; NULLs and summarising data quiz; Joining tables; and more.
What level is SQL for Beginners?
It's marked beginner level in Software Development.
More Software Development courses
- Agentic development foundations (Free)
- Agentic pipelines (Free)
- Autonomy you can trust (Free)
- Close the loop (Free)
- Learn TRMNLY (Free)
- Many agents at once (Free)