How to learn SQL
This path assumes you can use a spreadsheet and nothing else. It gets you to the point where you can write correct multi-table queries, explain why a query is slow by reading its plan, and design tables that do not fall apart under real volume. It takes 90-100 hours, most of it spent on a local PostgreSQL instance.
Hours
90-100 hours
Calendar
about 16 weeks at 6 hours a week
Stages
6
Start from
Nothing beyond basic computer use. The common belief that you need programming experience is wrong; SQL is declarative and the harder part is data modelling, not code.
Why the usual order fails
SQL syntax is small enough to memorise in a weekend: SELECT, FROM, WHERE, GROUP BY, a handful of joins. The actual skill is learning to stop thinking row by row and start thinking in sets. Most introductions teach syntax in isolation, then move to window functions and CTEs as if they were advanced toppings. That order fails because it never forces you to describe the result you want instead of the loop you would write in another language. You end up able to recite syntax and unable to write a query that survives contact with real data.
This path reverses the order. In week one you load a real dataset into PostgreSQL, write queries that return wrong row counts, and fix them by reading the data, not the syntax. Most plans have you still typing SELECT * from a single table at that point. By week four you are reading execution plans and rewriting a slow query, because that is when the set-based model becomes visible. You practise on one database engine throughout, so the behaviour you learn is consistent rather than a tour of dialects.
The path, in the order it has to be walked.
Each stage assumes the one above it and nothing below it. The check at the foot of each is the point — you are meant to fail it, go back, and try again before moving on.
Rows, tables and set selection
weeks 1-3 (18 hours)This stage establishes that SQL describes result sets, not loops. You work on a single table with enough rows to make incorrect WHERE clauses obvious. Joins are delayed because filtering and null handling must become automatic before row multiplication enters.
- SELECT list and aliases
- WHERE with AND, OR and NOT
- NULL and three-valued logic
- ORDER BY and LIMIT
- DISTINCT and duplicate rows
- LIKE, ILIKE and pattern matching
- date and timestamp filtering
- COUNT and basic aggregates
You can now: Given a 50,000-row table, write a query that returns the correct 127 rows for a date range within ten minutes.
Joins and grouping
weeks 4-6 (18 hours)Joins are where most learners stall because they memorise Venn diagrams instead of row multiplication. This stage forces you to predict row counts before running each join. Aggregation follows because GROUP BY changes the grain of the result and must be understood after joins.
- INNER JOIN
- LEFT, RIGHT and FULL OUTER JOIN
- CROSS JOIN and row multiplication
- self-join
- GROUP BY and HAVING
- SUM, AVG, MIN and MAX
- COUNT(*) versus COUNT(column)
- joining on multiple keys
You can now: Take two related tables and write a query that produces the exact expected row count and grouped totals without checking the output first.
Subqueries, CTEs and set operations
weeks 7-9 (18 hours)This stage replaces nested thinking with named intermediate results. It sits after joins because subqueries often hide a join that should be explicit. You learn to choose between a CTE, a subquery and a temporary table by reading the plan.
- scalar subqueries
- correlated subqueries
- EXISTS versus IN
- WITH and common table expressions
- recursive CTEs
- UNION, INTERSECT and EXCEPT
- ROW_NUMBER and RANK
- lateral joins
You can now: Rewrite a five-level nested query as three named CTEs and confirm both return the same 2,304 rows.
Indexes, execution plans and performance
weeks 10-12 (18 hours)This is the stage most learners never reach. You read actual execution plans, not textbook descriptions. It sits here because you now write queries complex enough to be slow. You learn that the planner's choices depend on statistics, not syntax.
- EXPLAIN and EXPLAIN ANALYZE
- sequential scans versus index scans
- B-tree indexes
- composite indexes
- covering indexes
- query planner statistics and ANALYZE
- identifying bottlenecks
- rewriting OR to UNION
You can now: Take a query that runs in 1.8 seconds on 2 million rows, add one composite index, and reduce it to under 80 milliseconds while returning the same rows.
Data modelling and normalisation
weeks 13-14 (12 hours)You cannot write reliable SQL against a poorly designed schema. This stage teaches you to design tables before querying them. It sits after performance work because you now know which designs cause slow joins and missing indexes.
- primary and foreign keys
- first, second and third normal form
- denormalisation trade-offs
- many-to-many junction tables
- one-to-one and one-to-many relationships
- data types and constraints
- CHECK and NOT NULL
- designing against update anomalies
You can now: Given a spreadsheet of orders and products, produce a normalised schema with junction tables and load it without duplicate or orphan rows.
Transactions and window functions
weeks 15-16 (12 hours)This final stage combines correctness under concurrency with analytical queries. Transactions matter because real databases have simultaneous writers, not just readers. Window functions finish the set-based model by computing across rows without collapsing them.
- BEGIN, COMMIT and ROLLBACK
- isolation levels
- locking and deadlocks
- ACID properties
- window frames and PARTITION BY
- running totals and moving averages
- LAG and LEAD
- integrity constraints in practice
You can now: Write a transaction that transfers stock between two warehouses and a window query that produces a correct running total for 100,000 rows.
The hours are fixed. The calendar is yours.
The same path at three speeds, and what actually goes wrong at each.
3 hours a week
At this pace the 90-100 hours stretches to 30-34 weeks. You will forget join behaviour between sessions and spend the first 20 minutes of each week re-reading old queries. The performance stage becomes hard because you rarely build enough volume to see slow plans.
8 hours a week
This is the sustainable pace the path assumes. You finish in 11-13 weeks if you do every exercise, with enough time between sessions to retain what you practised. The risk is treating it as two evenings and skipping the row-count predictions that make joins stick.
20 hours a week
Finishing in 5 weeks sounds efficient but breaks the consolidation this subject needs. You will memorise syntax faster than you can internalise set-based reasoning, and the query plan stage arrives before you have written enough slow queries to care about it.
Four ways people lose a year on this.
Each of these is appealing for a real reason, which is why they are common. What they cost is the part nobody mentions.
Learning five SQL dialects at once
People try SQLite, MySQL, PostgreSQL and SQL Server in the same month because guides switch engines. Each has different date functions, string handling and LIMIT syntax. It feels thorough but leaves you unable to write one dialect fluently, and you spend your time looking up syntax instead of reading plans. This path uses PostgreSQL only.
Treating joins as Venn diagrams
The overlapping circles picture teaches you to think of joins as set intersection, but a join is row multiplication with a filter. Learners who rely on Venn diagrams cannot predict duplicate rows from one-to-many relationships, so their grouped totals are wrong. You need to see the row pairs before the diagram.
Using SELECT * in real queries
It is convenient while exploring, but in any query with joins or production code it returns unused columns, defeats covering indexes, and breaks when a table gains a column. The habit is hard to break because it feels harmless. It costs you performance and makes schema changes risky.
Optimising without reading the execution plan
People add indexes based on guesses or blog posts, then wonder why the query is still slow. The planner's choices depend on row estimates, data distribution and existing indexes, none of which are visible in the SQL text. You waste hours on indexes that never get used.
How to know it worked.
Not a syllabus you tick off — six things to attempt. If one of them is still hard, the stage it belongs to is the one to go back to.
- Write a query that returns all rows where a date column is in the last 30 days.
- Predict the row count of a two-table join before running it.
- Rewrite a query using a correlated subquery as a join and compare the plans.
- Read an EXPLAIN ANALYZE output and name the most expensive node.
- Design a normalised schema for a library's books, authors and loans.
- Write a transaction that moves money between two accounts and rolls back on failure.
Questions about learning SQL.
The five we hear most. The intro film answers most of them in a minute and a half.
how long does it take to learn sql
Expect 90-100 hours of deliberate practice to reach working competence, not a weekend. That includes writing queries against datasets large enough to expose mistakes, reading execution plans, and designing schemas. You can write a basic SELECT in an afternoon, but thinking in sets and diagnosing performance takes months at a few hours a week.
is sql hard to learn
The syntax is not hard; the shift from row-by-row thinking to set-based thinking is. Most people can write a working query in a day, but they produce incorrect row counts on joins for weeks. The difficulty is not memorising keywords but predicting what a query returns before running it.
do i need to know programming before learning sql
No. SQL is declarative, so you describe the result rather than write loops or variables. Programming experience can even get in the way, because you try to solve problems row by row. Spreadsheet familiarity is more useful, since filtering and grouping resemble what you already do.
which sql database should i learn first
Pick one and stay with it for at least three months. PostgreSQL is a good default because its EXPLAIN output is readable and its behaviour is standard. Switching between MySQL, SQLite and SQL Server early costs you fluency in date functions, string handling and plan reading without teaching transferable skill.
is sql enough to get a data job
SQL alone is rarely enough for a data analyst role, but it is the most common hard requirement. You also need to present findings and understand the business problem. For data engineering, add a scripting language and data modelling. SQL is necessary, but not sufficient.
A path is not a course.
This is the shape of SQL, not the teaching of it. Hand the same path to BiliMind and it writes the lessons onto it — in the form each one calls for, with practice that gets marked and a schedule that bends when your week does. Mapping a course is free and unlimited.
This roadmap was drafted on 18 September 2026 by the same engine that builds BiliMind courses, and reviewed before publishing. Hours are honest estimates for working competence, not for a demo — treat them as a starting point and adjust them against your own first fortnight.

