SQL
Why does SQL exist?
Imagine you work at a store and your boss asks: "How much did each product category earn last month?"
Your data is in a spreadsheet. If you have a hundred rows, you can filter and scroll through it. But most real businesses have millions of rows — too many to scan by hand, too big for Excel to even open.
A database is a system built to hold that much data and search it fast. SQL is the language you use to ask it questions.
You write something like:
SELECT category, SUM(revenue)
FROM sales
WHERE month = 'January'
GROUP BY category
And in under a second, the database hands you exactly the answer. No scrolling. No pivot tables. No "my Excel crashed."
Almost all company data lives in a database. Sales records, user events, financial transactions, inventory — it is all there. SQL is the only language databases speak, which is why it is the first thing every data analyst learns.
What You'll Learn
- Writing queries to retrieve and filter data
- Aggregating and grouping records
- Joining multiple tables together
- Using subqueries and CTEs for readable, modular SQL
- Window functions for running totals, rankings, and comparisons
Lessons
Getting Started
| Lesson | Concept |
|---|---|
| Introduction to SQL | What SQL is, how databases work, and your first queries |
Your First Query
| Lesson | Concept |
|---|---|
| SELECT | Retrieve columns from a table |
| FROM | Specify the source table and use aliases |
| WHERE | Filter rows by a condition |
| AND / OR | Combine multiple filter conditions |
Filtering Techniques
| Lesson | Concept |
|---|---|
| IN | Match against a list of values |
| BETWEEN | Filter by an inclusive range |
| LIKE | Pattern matching on strings |
| IS NULL / IS NOT NULL | Check for missing values |
Shaping Results
| Lesson | Concept |
|---|---|
| AS | Alias columns and tables for readability |
| DISTINCT | Remove duplicate rows |
| ORDER BY | Sort the result set |
| LIMIT / TOP | Restrict the number of rows returned |
Joining Tables
| Lesson | Concept |
|---|---|
| JOIN | Combine matching rows from two tables |
| ON | Define the join condition |
| LEFT JOIN | Keep all left-side rows, NULL-fill the right |
Aggregating Data
| Lesson | Concept |
|---|---|
| Aggregate Functions | COUNT, SUM, AVG, MIN, MAX |
| GROUP BY | Group rows for aggregation |
| HAVING | Filter groups after aggregation |
How SQL Thinks
| Lesson | Concept |
|---|---|
| SQL Execution Order | The order SQL actually processes your query |
Writing Cleaner Queries
| Lesson | Concept |
|---|---|
| CASE WHEN | Conditional logic in queries |
| WITH (CTEs) | Named temporary result sets |
Window Functions
| Lesson | Concept |
|---|---|
| Window Functions | OVER, PARTITION BY - compute across rows without collapsing them |
| ROW_NUMBER / RANK / DENSE_RANK | Ranking rows within a partition |
| LAG / LEAD | Access values from adjacent rows |
| Running Totals & Moving Averages | Cumulative sums, sliding windows, and frame specs |
Set Operations & Subqueries
| Lesson | Concept |
|---|---|
| Subqueries | Scalar, table, and correlated subqueries |
| UNION / INTERSECT / EXCEPT | Combine result sets vertically |
| EXISTS / NOT EXISTS | Test for row presence safely |
Useful Functions
| Lesson | Concept |
|---|---|
| COALESCE / NULLIF | Handle NULLs gracefully |
| Date & Time Functions | Truncate, extract, and compute with dates |
No prior experience required. A basic understanding of spreadsheets is helpful but not necessary.