SQL for Data Analysis: A Step-by-Step Roadmap

Data analysts turn raw data into answers: which products sell, where customers drop off, whether this month is better than last. Almost all of that work starts with one skill: SQL.

This roadmap shows what to learn, in what order, to use SQL for real data analysis. Each stage links to a free tutorial on this site and ends with a short “you’re ready when” check. Work through it in about 8 to 10 weeks at an hour a day.

SQL for data analysis roadmap in 9 stages: basics, summarize, clean, statistics, window functions, funnels and cohorts, data models, performance, tools around SQL

What does a data analyst actually do with SQL?

A typical request sounds like this: “Why did online sales drop last month?” To answer it, an analyst:

  1. Finds the data: which tables hold orders, customers and website visits.
  2. Cleans it: removes duplicates, fixes dates, handles missing values.
  3. Summarizes it: totals, averages and medians by month, product or region.
  4. Compares: this month vs last month, mobile vs desktop, new vs returning customers.
  5. Explains: a short table or chart with a clear answer, like “Mobile checkout conversion fell from 30% to 12% after the app update.”

SQL handles steps 1 to 4. The stages below follow the same order.

Stage 1: SQL basics

Everything else builds on reading data from a table, filtering it, sorting it and combining tables.

You’re ready when you can write a query that joins orders to customers, keeps only last month’s orders from one country, and sorts them by amount.

Stage 2: summarize data

Analysis is mostly summarizing. Learn to count, sum and average by group, and to filter groups.

You’re ready when you can produce “orders, revenue and average order value per month, per country”, and list only countries with more than 100 orders.

Stage 3: clean the data

Real data is messy, and wrong input gives confident wrong answers. Learn to find and fix the problems before you calculate anything.

You’re ready when you can take a messy imported table, profile it, and write one query that produces a clean, typed, de-duplicated version, plus a before-and-after count.

Stage 4: describe the numbers (statistics)

An average alone can mislead. Learn the handful of statistics every analyst uses, and how to get them in SQL.

You’re ready when you can explain why the median order is 25 while the average is 112, and find the order that causes it.

Stage 5: window functions and reporting queries

This is the stage that separates beginners from analysts. Window functions let you compare each row with others: running totals, rankings, the previous month, the share of total.

You’re ready when you can show each month’s revenue next to the previous month’s, with the percentage change, in one query.

Stage 6: business analysis patterns

Now put it together into the analyses that companies ask for again and again.

  • Funnel Analysis in SQL (coming soon): where users drop off between visit and purchase, and how it differs by device.
  • Cohort and Retention Analysis in SQL (coming soon): do customers come back, and is it getting better?

Other patterns worth practicing with the same tools:

  • Month-over-month growth: LAG on a monthly summary.
  • Top customers and the 80/20 rule: running share of revenue with SUM() OVER (ORDER BY revenue DESC).
  • Basket analysis: which products are bought together, with a self join on order lines.
  • A/B test results: conversion rate per test group, using the same counts as a funnel.

You’re ready when you can take a question like “Are customers from our summer campaign worth more than others?” and turn it into cohorts, a query and a one-line answer.

Stage 7: understand where analysis data lives

You don’t need to become a data engineer, but you’ll work faster when you know why reporting data is shaped the way it is.

You’re ready when you can look at a FactSales table and its dimensions and write a monthly sales-by-category report without help.

Stage 8: make queries fast enough

Analysis queries scan a lot of rows. A little performance knowledge saves you from waiting minutes for each answer, or from slowing down the live system for everyone else.

You’re ready when you can explain why a query is slow and rewrite a filter so it can use an index.

Stage 9: the tools around SQL

SQL gets and shapes the data. Other tools present it or take it further:

  • Excel: still the most common place results end up. See SQL vs Excel: What’s the Difference?
  • Python and pandas: for statistics, charts and machine learning. See SQL vs Python (pandas) for Data Analysis (coming soon).
  • BI tools such as Power BI, Tableau or Looker Studio: connect to your database and turn SQL views into dashboards.
  • Data science: when you move from describing what happened to predicting what will happen. See A Beginner’s Guide to the Data Science Lifecycle.

An 8-week study plan

WeekFocusPractice
1Stage 1: SELECT, WHERE, JOINs20 small queries on a sample database
2Stage 2: GROUP BY, HAVING, CASEMonthly sales summary by country
3Stage 3: cleaning, NULLs, datesClean a messy CSV you download
4Stage 4: statisticsAverage vs median report with outliers
5Stage 5: window functions, CTEsMonth-over-month growth, top 3 per group
6Stage 6: funnel and cohortsBuild both on a sample events/orders table
7Stages 7-8: warehouses and speedRead execution plans of your slowest queries
8Stage 9 + a projectOne complete analysis, written up

Free practice data is easy to find: Microsoft’s sample databases (AdventureWorks, WideWorldImporters) for SQL Server, the Sakila and Employees databases for MySQL, or any CSV from a public open-data portal loaded into a table.

Your first portfolio project

When you apply for analyst jobs, one finished project is worth more than ten certificates. A simple structure that works:

  1. A question: “Which customers stop buying, and when?”
  2. The data: a public sales dataset loaded into SQL Server or MySQL.
  3. The cleaning: the queries from Stage 3 and a note of what you fixed.
  4. The analysis: a cohort table, a funnel or a monthly trend, with the SQL.
  5. The answer: three findings in plain English and one chart.

Put the SQL and the write-up on GitHub or a simple blog. Interviewers will ask you about it, and you’ll have real answers.

Common mistakes on the way

  • Jumping to Python or dashboards before SQL. Every one of those tools needs data, and the data comes out of SQL.
  • Trusting the data without checking it. Always profile and clean first (Stage 3).
  • Reporting only averages. Show medians and counts too, so one big order doesn’t tell the whole story.
  • Writing one giant query. Use CTEs to build the analysis in small steps you can check one at a time.
  • Not stating definitions. “Active customer”, “conversion” and “month” can each mean several things. Write down which one you used.

Summary

  • SQL is the core skill of data analysis: finding, cleaning, summarizing and comparing data.
  • Learn it in order: basics, summarizing, cleaning, statistics, window functions, business patterns, data models, performance, then the tools around SQL.
  • Practice every stage on real data, and finish with one complete project.
  • Add Python, Excel and BI tools on top of SQL, not instead of it.

The SQL for Data Analysis series

  1. Data Cleaning in SQL
  2. Basic Statistics in SQL
  3. Funnel Analysis in SQL (coming soon)
  4. Cohort and Retention Analysis in SQL (coming soon)
  5. SQL vs Python (pandas) for Data Analysis (coming soon)
  6. SQL for Data Analysis: A Step-by-Step Roadmap (this page)

Related articles

Scroll to Top