SQL Tutorials
Write efficient queries — joins, subqueries, window functions, and database optimisation.
Introduction to SQL & Databases
Understand what SQL is, how relational databases work, and set up your environment to start writing queries.
SELECT Queries — The Foundation
Master the SELECT statement — choosing columns, aliasing, expressions, and writing clean, readable queries.
Filtering Data with WHERE
Use the WHERE clause to filter rows using comparison operators, logical operators, LIKE, IN, BETWEEN, and NULL checks.
Sorting, LIMIT & DISTINCT
Control the order, number, and uniqueness of rows returned — ORDER BY, LIMIT, OFFSET, and DISTINCT in depth.
Aggregate Functions
Calculate counts, sums, averages, and more across rows of data using COUNT, SUM, AVG, MIN, MAX, and related functions.
GROUP BY & HAVING
Group rows into sets and compute aggregates per group, then filter groups with HAVING.
Joins — Combining Tables
Combine data from multiple tables using INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, CROSS JOIN, and self joins.
Subqueries & Nested Queries
Write queries inside queries — scalar subqueries, correlated subqueries, EXISTS, IN with subqueries, and derived tables.
INSERT, UPDATE & DELETE (DML)
Add, modify, and remove data in your tables using INSERT, UPDATE, and DELETE — safely and precisely.
CREATE, ALTER & DROP (DDL)
Define and modify database structure — create tables, alter columns, rename objects, and safely remove them.
Constraints & Data Integrity
Enforce data quality with PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, and DEFAULT constraints.
Indexes & Query Performance
Speed up queries with indexes — understand how they work, when to use them, and how to avoid common pitfalls.
Views & Virtual Tables
Create reusable, named query results as views — simplify complex queries, restrict data access, and create abstraction layers.
Stored Procedures & Functions
Package reusable SQL logic in the database — stored procedures, user-defined functions, parameters, and control flow.
Window Functions
Perform advanced analytics without collapsing rows — RANK, ROW_NUMBER, DENSE_RANK, LAG, LEAD, running totals, and moving averages.
CTEs & Set Operations
Write readable multi-step queries with Common Table Expressions (WITH), recursive CTEs, and combine result sets with UNION, INTERSECT, and EXCEPT.
Transactions & ACID
Ensure data integrity with transactions — BEGIN, COMMIT, ROLLBACK, SAVEPOINT, isolation levels, and the ACID properties.
Database Design & Normalization
Design efficient, consistent schemas — entity-relationship modeling, normalization (1NF through 3NF/BCNF), denormalization trade-offs, and real-world design patterns.