All coursesData

Learn to ask a database anything.

  • Free
  • 8 weeks
  • Beginner → Intermediate
See the outline

Read the guide: How to learn SQL for data analysis: an 8 week plan

Relational database analytics, metrics breakdown, and query performance on a studio laptop
Accredited Curriculum & Certification
Official Syllabus Snapshot

Direct Answer: Learn to ask a database anything — from your first SELECT to window functions, query plans, and turning a vague business question into a number you can defend.

Tuition Fee
100% Free
Duration & Workload
~11 Hours
Curriculum Depth
12 Chapters · 48 Lessons
Credential Awarded
Verified Certificate
12Chapters

Course outline

The relational model, the schema this whole course uses, and your first real queries.

  • Rows, Keys, and the Shape of a Database12 min
  • SELECT, WHERE, and ORDER BY13 min
  • NULLs, Text, and Dates Without Lying13 min
  • Stacking Results with UNION, INTERSECT, and EXCEPT13 min

Collapsing thousands of rows into the handful of numbers someone actually asked for.

  • COUNT, SUM, AVG and the Rules They Follow13 min
  • GROUP BY: One Row Per Group14 min
  • HAVING vs WHERE, and the Order SQL Really Runs In13 min
  • Median, Percentiles, and When the Average Lies13 min

Every join type with worked results, and the three ways joins produce confidently wrong numbers.

  • INNER JOIN: Matching Rows Across Tables13 min
  • LEFT, RIGHT, FULL, and CROSS JOIN14 min
  • Fan-out, Anti-joins, and Self-joins14 min
  • Non-equi Joins: Matching on Ranges, Not Equality13 min

Composing queries out of named steps, and computing across rows without collapsing them.

  • Subqueries: Scalar, IN, and EXISTS13 min
  • CTEs: Naming the Steps of a Query13 min
  • Window Functions: Ranking and Running Totals15 min
  • Frames, Moving Averages, and the LAST_VALUE Trap14 min

Fixing messy data in SQL, making queries fast on purpose, and designing tables that stay correct.

  • Cleaning Messy Data in SQL14 min
  • Indexes and Reading a Query Plan14 min
  • Normalisation, Denormalisation, and the Analyst's Workflow15 min
  • Constraints: Making Bad Rows Impossible13 min

Inserts, updates and deletes you can run against a live table, and loads that survive being run twice.

  • INSERT, UPDATE, DELETE Without Regret14 min
  • Transactions and the Lost Update14 min
  • Idempotent Loads: UPSERT, MERGE, and Re-runnable Pipelines15 min
  • Schema Changes on a Live Table13 min

Models other people depend on, tests that fail loudly when the data goes wrong, and the rules for running SQL inside an application.

  • Views, Materialised Views, and Layered Models14 min
  • Testing Data: Assertions That Fail Loudly14 min
  • Running SQL Inside an Application15 min
  • Finding the Query That Is Hurting You13 min

The analysis people start asking once they trust your models, from subtotals in a single pass to retention curves built out of raw event logs.

  • GROUPING SETS, ROLLUP, and Subtotals in One Pass13 min
  • LATERAL Joins and Correlated Top-N Per Group13 min
  • Recursive CTEs: Trees, Paths, and Generated Series13 min
  • Sessions, Funnels, and Retention Cohorts13 min

Reading the planner's reasoning instead of arguing with it, feeding it better statistics and access paths, and rewriting the queries it can never fix on its own.

  • Statistics, Cardinality, and Why Estimates Go Wrong13 min
  • Nested Loop, Hash, and Merge Joins13 min
  • Beyond the B-tree: Partial, Covering, and GIN Indexes13 min
  • Rewriting a Query the Planner Cannot Fix13 min

What the database actually does when hundreds of sessions touch the same rows at once, and the slow mornings that follow one transaction nobody closed.

  • MVCC: How Readers and Writers Avoid Each Other13 min
  • Isolation Levels and the Anomalies They Allow13 min
  • Lock Modes, Blocked Queries, and Deadlocks13 min
  • Long Transactions, Bloat, and VACUUM13 min

Tables that outgrew a single index, engines that charge you by the byte scanned, and the answers that are worth approximating.

  • Partitioning, Pruning, and Retiring Old Data13 min
  • Row Stores, Column Stores, and Why Warehouses Are Different13 min
  • Clustering, Scan Cost, and the Query That Costs Money13 min
  • Approximate Answers: Sampling and HyperLogLog13 min

Modelling history so that last quarter still reports the same figure it did last quarter, and owning the definitions every dashboard in the company inherits.

  • Star Schemas and Choosing the Grain13 min
  • Slowly Changing Dimensions and As-Of Joins13 min
  • Late Arriving Data, Backfills, and Restatements13 min
  • Metric Contracts, Row-Level Security, and Audit Trails13 min

Final exam & certificate

  1. 01

    Topic checks

    Each one opens the next topic

  2. 02

    Chapter quizzes

    Each one opens the next chapter

  3. 03

    50-question final

    50 of 100 marks to pass

  4. 04

    Certificate

    Issued instantly, verifiable

One attempt, 60 minutes. If you don't pass, you can retake once after 30 days.

The course guide

How to learn SQL for data analysis: an 8 week plan

A wall of wooden library card catalogue drawers, each with a small paper label and a metal handle

To learn SQL for data analysis, install a free database such as PostgreSQL, load one small dataset you understand, and learn the language in this order: SELECT and WHERE, then aggregation with GROUP BY, then joins, then CTEs and window functions. At every step, check your answer against something you can count by hand. The syntax takes a few weeks. Learning to notice when a query returns a confident, wrong number is the real skill, and it is the part most tutorials skip.

This guide gives you an 8 week roadmap, the mistakes that catch almost every beginner, and a chapter by chapter look at our free SQL & Data Analysis course, which teaches all of it on one small store database so every lesson builds on the one before.

Why SQL is the core skill for data analysis

Spreadsheets are where most analysis starts, and they stay useful. But once the data lives in a company database, someone has to ask that database a question in its own language. That language is SQL, and its core has stayed stable for decades, so what you learn now keeps paying off.

A query is written down, so someone else can read it, rerun it next month and check your logic. That is why analyst roles so often list it, and why our guide on how to become a data analyst in Pakistan puts it straight after spreadsheets.

You do not need to be a programmer. SQL is declarative: you describe the result you want, and the database works out how to get it. If you can build a PivotTable, you already think in the right shapes.

Architectural Blueprint and Learning Stages for How to learn SQL for data analysis: an 8 week plan — Cortexis Roadmap Diagram
Figure 1: Complete step-by-step architectural workflow and technical execution stages for How to learn SQL for data analysis: an 8 week plan.

What you need before you start

Very little:

  • A laptop. Anything that runs a modern browser will do.
  • A free database. PostgreSQL is free and open source, and it is what the course uses for most examples. SQLite is even lighter: a single file, no server. The course points out where MySQL and SQLite behave differently, for example in case sensitivity and in how strictly GROUP BY is enforced.
  • One dataset you understand. Customers, orders and products is ideal, because you already know what the right answer should look like.

How to learn SQL for data analysis: an 8 week roadmap

Plan on about an hour a day, five days a week.

WeekFocusYou can answer
1Tables, keys, SELECT, WHERE, ORDER BY, NULLs, dates"Which orders were placed in June?"
2COUNT, SUM, AVG, GROUP BY, HAVING, medians"Revenue per category, only categories above a threshold"
3INNER, LEFT and other joins, anti-joins, self-joins"Which customers have never ordered?"
4Subqueries, CTEs, window functions"Each customer's running total and rank"
5Cleaning messy data, indexes, query plans, constraints"Why does this report take minutes?"
6INSERT, UPDATE, DELETE, transactions, safe reloads"Can I fix this data without breaking it?"
7Views, data tests, ROLLUP, funnels, retention cohorts"Monthly retention by signup cohort"
8Practice project and reviewA written analysis someone else can rerun

Weeks 1 and 2: rows into answers

Start with the shape of a table: one row states one fact about one thing, and keys connect tables to each other. Then filter and sort. Spend real time on NULL, because WHERE city <> 'Lahore' quietly drops every customer whose city is missing, and nothing warns you.

Aggregation comes next. Learn exactly what COUNT(*) counts compared with COUNT(column), and why a filter on individual rows belongs in WHERE while a filter on a group's total belongs in HAVING. Learn the median too, because a single huge order can drag an average far away from what a typical customer spends.

Weeks 3 and 4: joins and windows

Joins are where wrong answers come from. When you join orders to order items, each order appears once per line item, so summing the order total afterwards counts it several times. Revenue looks healthy and is simply false. The fix is to aggregate the line items to one row per order first, then join.

After joins, CTEs let you name each step of a query so you can test them one at a time. Window functions then let you rank, compute running totals and compare a row with the previous one without collapsing your rows. Many analyst interview questions live here.

Weeks 5 to 8: from correct to dependable

Analysts who last learn why a query is slow, how to clean text and dates inside SQL, how to change data without regret, and how to write tests that fail loudly when the data goes wrong. Finish with one project: a question about your store data, the queries that answer it, and a short write-up of what you found and what you could not prove.

Common mistakes to avoid

These are the ones the course builds whole lessons around:

  1. The join that doubles revenue. Always check the row count before and after a join. If it grew and you did not expect it to, stop.
  2. BETWEEN on timestamps. BETWEEN '2024-06-01' AND '2024-06-30' misses almost all of the last day when the column holds times. Use >= '2024-06-01' AND < '2024-07-01' instead.
  3. Integer division. In PostgreSQL, 4 / 6 is 0. Multiply by 100.0 first when you want a percentage.
  4. Filtering on a window function in WHERE. Window functions run after WHERE, so wrap the query in a CTE and filter outside it.
  5. Building SQL by gluing strings together. In an application, pass values as bound parameters. Escaping quotes by hand is how SQL injection happens.
  6. Trusting a number you never checked. Pick one customer, count their orders by hand, and confirm your query agrees.

What the free SQL & Data Analysis course covers

The SQL & Data Analysis course is rated Beginner to Intermediate and planned as 8 weeks of study. It has 12 chapters of 4 lessons each, 48 lessons in all, and most lessons take about 12 to 15 minutes to read. Every example uses the same four tables: customers, products, orders and order items.

ChapterWhat you learn
1. Thinking in TablesKeys, SELECT, WHERE, ORDER BY, NULLs, text and dates, UNION and EXCEPT
2. Aggregation: Rows Into AnswersCOUNT, SUM, AVG, GROUP BY, HAVING vs WHERE, medians and percentiles
3. Joining TablesEvery join type, fan-out, anti-joins, self-joins, range joins
4. Subqueries, CTEs, and Window FunctionsEXISTS, named steps, ranking, running totals, moving averages
5. Clean Data, Fast Queries, Good SchemasCleaning in SQL, indexes, query plans, normalisation, constraints
6. Changing Data SafelyINSERT, UPDATE, DELETE, transactions, UPSERT, live schema changes
7. Putting a Query Into ProductionViews, data tests, SQL inside applications, finding slow queries
8. Questions That Do Not Fit a GROUP BYROLLUP, LATERAL joins, recursive CTEs, funnels and retention cohorts
9. Why the Planner Chose That PlanStatistics, join algorithms, partial and covering indexes, rewrites
10. Concurrency Under Real TrafficMVCC, isolation levels, locks, deadlocks, VACUUM
11. Big Tables, Warehouses, and the BillPartitioning, column stores, scan cost, approximate counts
12. The Numbers the Company Runs OnStar schemas, slowly changing dimensions, backfills, metric contracts

Chapters 1 to 4 are the core of analyst SQL. Chapters 5 to 8 make you the person whose numbers others trust. Chapters 9 to 12 go further than most analyst roles need on day one, into the territory where analysis meets data engineering, so treat them as a second pass once the basics are solid.

Who this course is for, and who it is not for

It suits students, Excel users who keep hitting the limits of their spreadsheets, and junior analysts who can write a query but are not sure they trust the result. It assumes no programming background.

It is not a full analyst career path on its own. If you also want spreadsheets, statistics and presenting results, the Data Analyst Bootcamp covers that wider ground. If you are still more comfortable in spreadsheets, our guide on how to use Excel for data analysis and the Excel for Business Analytics course are a gentler start. Once your queries work, Power BI & Business Intelligence turns them into dashboards.

How the free certificate works

Each lesson ends with a short quiz you pass to open the next lesson, and each chapter ends with a chapter quiz. You need 70 percent on a chapter quiz to open the next chapter, so you cannot skim ahead without the foundations.

When every lesson is complete and every chapter quiz is passed, the final exam unlocks: 50 questions, 60 minutes, and a pass mark of 50 out of 100. You get one timed attempt. If you do not pass, a retake opens 30 days later. Pass it and your certificate is issued free.

Be honest with yourself about what that certificate proves. It shows you finished a demanding course and passed a timed exam. An employer will learn more from a short project where you explain a query, the check you ran on it, and the mistake you caught.

Questions, answered

06 questions