SQL
Query, join, aggregate and tune relational data.
7 pages, free to read
- 1
SELECT, WHERE & ORDER BY
BeginnerSELECT picks the columns, WHERE keeps only the rows that pass a condition, and ORDER BY sorts what is left; without ORDER BY the database promises no order at all.
8 min read - 2
Joins
BeginnerA join combines rows from two tables by matching them on a condition; the join type decides what happens to rows that have no match.
10 min read - 3
GROUP BY & aggregates
BeginnerGROUP BY collapses rows that share the same key into one row per group, aggregates like COUNT and SUM summarise each group, and HAVING filters the groups.
9 min read - 4
Subqueries & CTEs
IntermediateA subquery is a query inside another query, and a CTE (WITH ...) gives that inner query a name so you can build a complex query in readable steps, including recursive ones that walk hierarchies.
10 min read - 5
Window functions
IntermediateA window function computes a value for each row from a set of related rows (its window), such as a rank, a running total or the previous row's value, without collapsing rows the way GROUP BY does.
11 min read - 6
Indexes & query performance
IntermediateAn index is a sorted lookup structure (usually a B-tree) that lets the database jump straight to matching rows in O(log n) instead of scanning the whole table, at the cost of extra storage and slower writes.
12 min read - 7
Transactions & isolation levels
AdvancedA transaction groups several statements into one all-or-nothing unit (ACID), and its isolation level decides how much concurrent transactions can see of each other's unfinished or newly committed work.
12 min read