SQL is the standard language for asking questions of relational data and for changing it. You describe the result you want, not the steps to compute it, and the database decides how. It is one of the most durable skills in computing, used by analysts, backend developers and administrators alike.
Key concepts
- Declarative queries: you state what rows you want; the planner picks scans, indexes and join methods.
- Joins: combine tables on matching keys; inner, left, right and full joins differ in which unmatched rows survive.
- Aggregation: group rows and compute counts, sums and averages, then filter the groups.
- Set thinking: a table is a set of rows, so work on whole sets rather than looping row by row.
- Constraints: primary and foreign keys, uniqueness and checks keep bad data out.
Vocabulary
- NULL: a marker for an unknown value; comparisons with it are neither true nor false.
- Window function: a calculation across related rows that keeps each row, such as a running total.
- CTE: common table expression, a named subquery that makes a long query readable.
- DDL and DML: statements that define structure, and statements that read or change data.
What to study, in order
- Select, filter, sort and limit rows from a single table.
- Join two and then three tables, and predict the row count before running it.
- Group, aggregate and filter groups; learn why NULL needs special handling.
- Subqueries, CTEs and window functions on a real dataset.
- Design tables with keys and constraints, and insert, update and delete safely inside a transaction.
- Read a query plan, add an index and measure a slow query before and after.