SQL Tutorials

Write efficient queries — joins, subqueries, window functions, and database optimisation.

Start Learning
18Chapters
2h 38mtotal reading
Beginner to Advanced
Chapter 1

Introduction to SQL & Databases

Understand what SQL is, how relational databases work, and set up your environment to start writing queries.

9 min read|
SQLDatabasesRDBMS
Chapter 2

SELECT Queries — The Foundation

Master the SELECT statement — choosing columns, aliasing, expressions, and writing clean, readable queries.

8 min read|
SQLSELECTQueries
Chapter 3

Filtering Data with WHERE

Use the WHERE clause to filter rows using comparison operators, logical operators, LIKE, IN, BETWEEN, and NULL checks.

9 min read|
SQLWHEREFiltering
Chapter 4

Sorting, LIMIT & DISTINCT

Control the order, number, and uniqueness of rows returned — ORDER BY, LIMIT, OFFSET, and DISTINCT in depth.

8 min read|
SQLORDER BYLIMIT
Chapter 5

Aggregate Functions

Calculate counts, sums, averages, and more across rows of data using COUNT, SUM, AVG, MIN, MAX, and related functions.

7 min read|
SQLAggregateCOUNT
Chapter 6

GROUP BY & HAVING

Group rows into sets and compute aggregates per group, then filter groups with HAVING.

8 min read|
SQLGROUP BYHAVING
Chapter 7

Joins — Combining Tables

Combine data from multiple tables using INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, CROSS JOIN, and self joins.

9 min read|
SQLJOININNER JOIN
Chapter 8

Subqueries & Nested Queries

Write queries inside queries — scalar subqueries, correlated subqueries, EXISTS, IN with subqueries, and derived tables.

8 min read|
SQLSubqueriesNested Queries
Chapter 9

INSERT, UPDATE & DELETE (DML)

Add, modify, and remove data in your tables using INSERT, UPDATE, and DELETE — safely and precisely.

8 min read|
SQLINSERTUPDATE
Chapter 10

CREATE, ALTER & DROP (DDL)

Define and modify database structure — create tables, alter columns, rename objects, and safely remove them.

9 min read|
SQLDDLCREATE TABLE
Chapter 11

Constraints & Data Integrity

Enforce data quality with PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, and DEFAULT constraints.

9 min read|
SQLConstraintsPRIMARY KEY
Chapter 12

Indexes & Query Performance

Speed up queries with indexes — understand how they work, when to use them, and how to avoid common pitfalls.

9 min read|
SQLIndexesPerformance
Chapter 13

Views & Virtual Tables

Create reusable, named query results as views — simplify complex queries, restrict data access, and create abstraction layers.

8 min read|
SQLViewsCREATE VIEW
Chapter 14

Stored Procedures & Functions

Package reusable SQL logic in the database — stored procedures, user-defined functions, parameters, and control flow.

8 min read|
SQLStored ProceduresFunctions
Chapter 15

Window Functions

Perform advanced analytics without collapsing rows — RANK, ROW_NUMBER, DENSE_RANK, LAG, LEAD, running totals, and moving averages.

10 min read|
SQLWindow FunctionsRANK
Chapter 16

CTEs & Set Operations

Write readable multi-step queries with Common Table Expressions (WITH), recursive CTEs, and combine result sets with UNION, INTERSECT, and EXCEPT.

9 min read|
SQLCTEWITH
Chapter 17

Transactions & ACID

Ensure data integrity with transactions — BEGIN, COMMIT, ROLLBACK, SAVEPOINT, isolation levels, and the ACID properties.

10 min read|
SQLTransactionsACID
Chapter 18

Database Design & Normalization

Design efficient, consistent schemas — entity-relationship modeling, normalization (1NF through 3NF/BCNF), denormalization trade-offs, and real-world design patterns.

12 min read|
SQLDatabase DesignNormalization