Course Introduction
Welcome to Foundations - SQL
Foundations - SQL is the first of the four SQL courses on CodePeet. It starts with what a database is and ends with the CASE WHEN statement: 102 lessons in 12 sections, in this order: Getting Started, Introduction to SQL, SELECT Queries, Data Definition (DDL), Data Manipulation (DML), Filtering Data, SQL Joins, SQL SET Operators, String Functions, Date & Time Functions, NULL Functions and CASE WHEN Statement.
The three courses after it take the same language further: Advanced Queries - SQL (window functions, subqueries, CTEs and views), Production SQL & Engineering (temporary tables, stored procedures, indexes, partitions, performance, and AI assistants for writing SQL) and Real-World SQL Projects (a data warehouse, an exploratory analysis and an advanced analytics project).

In this course you will learn:
- how a database keeps information in tables, and the commands that create and change them
- how to ask a table for exactly the rows and columns you want: filter them, sort them, group and count them
- how to combine tables, with joins and with set operators
- how to clean and reshape values: text, dates, missing values, and CASE WHEN
What You Will Achieve
By the end of this course, you will be able to:
Query Data With Confidence
Write queries that choose columns, filter rows with WHERE and its operators, sort with ORDER BY, group with GROUP BY and HAVING, and combine tables with joins and with UNION, EXCEPT and INTERSECT.
Read How Tables Connect
See how a database is laid out: tables of rows and columns, and the columns two tables share. In the course's data, every order carries a customer_id, and the customers table has a row with the same customer_id for each of the 99,441 orders. That shared value is what a join matches on.
Summarise Data
Count, add up and average groups of rows with COUNT, SUM and AVG, and reshape text, dates and missing values with SQL's functions.
Write SQL That Travels
The queries in this course run on SQLite. Their core, SELECT with WHERE, GROUP BY and ORDER BY, is standard SQL that PostgreSQL, MySQL, SQL Server and Oracle run too. Joins, set operators and functions differ more from one database to another; where they do, the lessons say so.
Who Is This Course For?
This course is for:
| Who | What you get |
|---|---|
| Complete beginners | A foundation in databases and SQL, from the start |
| Students | SQL for coursework in computer science and data |
| Aspiring data analysts | The queries behind the analysis you will do |
| Software developers | The database side of the applications you build |
| Business professionals | Answers from data without waiting for someone else to query it |
| Career changers | A first technical skill to build on |
Prerequisites
No programming or database experience is needed. You need:
- a computer with an internet connection
- a CodePeet account, to run the queries
- time to practise
How This Course Works
Read, Run, Change
The lessons mix four things:
- Explanations, one idea at a time.
- Figures that draw each idea.
- Queries you can run. Every SQL block in this course has a Run Code button, except the four in Environment Setup: SQL Server, SSMS and Databases, which are for a database you install yourself. Sign in, press it, and the query runs on CodePeet's servers against the course's database; the rows come back under the block. You can edit the query in the block and run your own version. A result of more than 30 rows shows its first 30 and says it was cut.
- Exercises. 90 of the 102 lessons have a Practice section. Each exercise sets a task and gives a worked query you can run and change.
Each run starts from the same database. A query can create tables of its own and change them, and they are gone when the run ends; the course's own tables cannot be changed.
The Data You Will Query
The course works on the Brazilian E-Commerce Public Dataset, which Olist, a Brazilian company that sells small shops' products on online marketplaces, published on Kaggle. Olist describes it as "real commercial data, it has been anonymised": the orders are real, and the people behind them appear only as long codes. On CodePeet it holds 9 tables, among them:
- 99,441 orders, placed from 4 September 2016 to 17 October 2018
- the customer behind each order, in 4,119 cities
- 32,951 products, 73 product categories and 3,095 sellers
- 103,886 payment records and 100,000 reviews
Real Data Has Gaps
It has the gaps real data has. 610 products have no category. 2,965 orders have no delivery date, and 8 of those are marked as delivered all the same. The geolocation table writes the city of São Paulo both as são paulo and as sao paulo. Later lessons show what each of these does to a query.
One Step at a Time
The sections build on one another: you select and filter one table before you join two, and you combine tables before the functions that clean and reshape their values.
Course Format
How a Lesson Is Laid Out
| Part | Lessons with it |
|---|---|
| Introduction: what it covers | 101 of 102 |
| Explanations: the idea, with queries to run | every lesson, 99 with queries |
| Practice: exercises, each with a worked query | 90 |
| Summary or Key Takeaways: what to remember | 99 |
How to Study
- Run every example, then change it and run it again: another column, a different filter, a mistake on purpose.
- Try each exercise before you run its worked query.
- Write down what is new to you, in your own words.
- Finish a section before you start the next: each one uses the ones before it.
Your First Steps
Next Lessons
- Course Resources: links to the documentation of SQLite and of other databases, and the dataset's tables.
- Course Roadmap & Structure: the plan of this course.
- Join the Community: where to get help and meet other learners.
Then What is SQL and What are Databases? starts the course. Setting up a database on your own computer is optional: Environment Setup: SQL Server, SSMS and Databases, at the end of Introduction to SQL, shows how.
Start Now
You can run a query now: sign in, open a lesson with SQL in it, and press Run Code. There is nothing to install.
Summary
What You Learned
- Foundations - SQL is the first of four SQL courses: 102 lessons in 12 sections, from what a database is to CASE WHEN.
- No experience is needed, and with a CodePeet account you can run every query in it.
- The queries run on SQLite, against real orders from a Brazilian online store, with the gaps real data has.
- Most lessons have exercises, each with a worked query to run and change.
- Each section builds on the ones before it.
Next Up
Continue to Course Resources, or go straight to What is SQL and What are Databases?.