All tutorials
SQL tutorials
Queries, joins, subqueries, window functions and database design for analytics work.
- Chapters
- 16
- Total reading
- 3h 50m
- Level
- Beginner to Advanced
Chapters
- Chapter 114 min readStart
SQL Intro — SELECT, WHERE, ORDER BY
Get started with SQL — the SELECT statement, filtering with WHERE, sorting with ORDER BY, and the basics of relational thinking. - Chapter 215 min readStart
SQL Joins — INNER, LEFT, RIGHT, FULL
Understand the four classical joins, the difference between INNER and LEFT, common pitfalls, and how to find missing matches. - Chapter 317 min readStart
SQL Window Functions
Master OVER, PARTITION BY, ROW_NUMBER, RANK, LAG and running totals — the most-asked topic in modern analytics interviews. - Chapter 416 min readStart
SQL Subqueries & CTEs
Master subqueries and Common Table Expressions (WITH) — when to use which, recursive CTEs, and writing readable analytical SQL. - Chapter 514 min readStart
SQL Aggregations Deep Dive
COUNT vs COUNT DISTINCT, conditional aggregation, GROUPING SETS, ROLLUP, CUBE, and the patterns that show up in real analytics work. - Chapter 615 min readStart
Filtering in Depth
Master the WHERE clause — comparison and logical operators, LIKE patterns, IN, BETWEEN, and the crucial rules for handling NULL. - Chapter 713 min readStart
Sorting, Limiting & Pagination
Order results precisely, remove duplicates with DISTINCT, and page through large result sets with LIMIT and OFFSET. - Chapter 814 min readStart
CASE & Conditional Logic
Add if/then logic to queries with CASE, handle NULLs with COALESCE and NULLIF, and pivot data with conditional aggregation. - Chapter 913 min readStart
Data Types & NULL
Choose the right column type, convert between types with CAST, and understand NULL's three-valued logic properly. - Chapter 1013 min readStart
String & Text Functions
Clean and transform text in queries — concatenation, case, trimming, substrings, replacement, and search. - Chapter 1114 min readStart
Date & Time Functions
Work with dates — the current time, extracting parts, date arithmetic, truncation for grouping, and formatting. - Chapter 1213 min readStart
Set Operations
Combine the results of two queries — UNION, UNION ALL, INTERSECT and EXCEPT — and when to reach for each versus a JOIN. - Chapter 1314 min readStart
INSERT, UPDATE & DELETE
Change data safely — insert rows, update and delete with a WHERE, upsert on conflict, and the habits that prevent disasters. - Chapter 1415 min readStart
Table Design & Constraints
Model data well — CREATE TABLE, primary and foreign keys, constraints that guard integrity, and a practical look at normalization. - Chapter 1515 min readStart
Indexes & Query Performance
Make queries fast — how indexes work, which columns to index, reading the query plan with EXPLAIN, and common performance pitfalls. - Chapter 1615 min readStart
Views, Transactions & Best Practices
Save queries as views, guarantee all-or-nothing changes with transactions, and finish with the habits of professional SQL.
