SQL Fundamentals
Query, summarise, join and change data in a relational database with SQL, practised in your browser.
Leads to: Data Analyst, Data Scientist, Machine Learning Engineer, Software Developer, Systems Analyst, Database Administrator, Mobile Developer, Web / Full-Stack Developer, Back-End Developer, QA / Test Engineer, Data Engineer, IT Project Manager
Before you start
This course builds on Digital Literacy for Tech & STEM Work. Take it first if you are new to the topic.
About this course
Data analysts, data scientists, developers, systems analysts, database administrators and IT project managers all need to get answers out of relational databases. This beginner course teaches SQL from the ground up using SQLite, which runs right in your browser, so there is nothing to install. You start with what tables, rows, keys and schemas are, then filter and sort rows with SELECT, WHERE and ORDER BY and compute new columns with string, date and math functions. The second module summarises data with COUNT, SUM and AVG, GROUP BY and HAVING, and shows how to handle missing values with NULL checks, COALESCE and CASE. The third module explains primary and foreign keys and combines tables with INNER JOIN and LEFT JOIN, including finding rows with no match. The last module changes data safely with INSERT, UPDATE and DELETE, defines tables with types and constraints, and wraps changes in transactions and views. Nearly every lesson ends with a query you write and check against a small, realistic table. The core SQL you learn carries over to PostgreSQL, MySQL and SQL Server, and lessons point out where those engines differ.
Course content
Module 1
Querying a Table
3 lessons · 1h 12mLearn what a relational database is, then filter, sort and reshape rows with SELECT, WHERE, ORDER BY and functions.
- 15mWhat a relational database isReading
Learn how relational databases store data in tables of rows and columns, and what keys and schemas are.
- 29mSELECT, WHERE, ORDER BYReading
Choose columns with SELECT, filter rows with WHERE, and sort and limit results with ORDER BY and LIMIT.
- 28mExpressions and functionsReading
Compute new columns with arithmetic and with string, date and math functions, without changing the stored data.
Module 2
Summarising Data
3 lessons · 1h 20mSummarise tables with COUNT, SUM and AVG, aggregate by group with GROUP BY and HAVING, and handle missing values with NULL checks and CASE.
- 29mCOUNT, SUM, AVGReading
Summarise a whole table into one row with COUNT, SUM, AVG, MIN and MAX, and see how NULLs affect the results.
- 27mGROUP BY and HAVINGReading
Aggregate rows per group with GROUP BY, and keep only the groups you want with HAVING.
- 24mNULLs and CASEReading
Handle missing values with IS NULL and COALESCE, and turn raw values into categories with CASE.
Module 3
Joining Tables
3 lessons · 1h 34mUnderstand primary and foreign keys, combine related tables with INNER JOIN, and find rows with no match using LEFT JOIN.
- 36mPrimary and foreign keysReading
Learn why data is split across tables, and how primary keys, foreign keys and junction tables connect them.
- 33mINNER JOINReading
Combine related rows from two tables with INNER JOIN and an ON condition, and filter the joined result.
- 25mLEFT JOIN and finding gapsReading
Keep every row from one table with LEFT JOIN, and find rows with no match using IS NULL.
Module 4
Changing Data
3 lessons · 1h 38mAdd, change and remove rows safely, define tables with types and constraints, and use views and transactions.
- 30mINSERT, UPDATE, DELETEReading
Add, change and remove rows with INSERT, UPDATE and DELETE, using WHERE and previews to stay safe.
- 33mCREATE TABLE and constraintsReading
Define a table with column types and constraints such as PRIMARY KEY, NOT NULL, UNIQUE, DEFAULT and CHECK.
- 35mViews and transactionsReading
Group changes into an all-or-nothing transaction with BEGIN and COMMIT, and save a reusable query as a view.