SQL for data analysis: from first query to window functions

Learn SQL on PostgreSQL with realistic sales data: filtering, joins, aggregation, dates, subqueries, CTEs and your first window functions

9 ratings 4,120 students Sample

Created by Aiko Tanaka

  • Updated September 2026
  • English
  • Beginner

What you will learn

  • Write SELECT queries that filter, sort and limit results correctly
  • Join several tables without duplicating or losing rows
  • Summarise data with GROUP BY, HAVING and conditional aggregation
  • Work with dates to build weekly and monthly reports
  • Structure longer queries with CTEs so others can read them
  • Use window functions for rankings, running totals and comparisons

Course content

6 sections, 25 lessons, 3h 59m total

Your first queries 5 lessons · 41 min
  • Video: What SQL is and how a query runs Preview 8 min
  • Article: Filtering with WHERE, and the trouble with NULL Preview 11 min
  • Article: Sorting, limiting and computing columns 9 min
  • Article: Checking your own results 8 min
  • Quiz: Check your understanding 5 min
Combining tables with joins 4 lessons · 42 min
  • Video: INNER JOIN and how keys connect tables 11 min
  • Video: LEFT JOIN for finding what is missing 10 min
  • Article: Joining many tables without multiplying rows 12 min
  • Video: Self joins and joining on ranges 9 min
Aggregation and grouping 4 lessons · 39 min
  • Video: COUNT, SUM, AVG and friends 9 min
  • Article: GROUP BY and HAVING 11 min
  • Video: Conditional aggregation with FILTER and CASE 10 min
  • Video: Percentages and ratios done right 9 min
Working with dates and time 4 lessons · 42 min
  • Article: Dates, timestamps and time zones 11 min
  • Video: Monthly and weekly reports with date_trunc 10 min
  • Video: Filling gaps with generate_series 9 min
  • Article: Cohorts: grouping customers by first purchase 12 min
Subqueries and CTEs 3 lessons · 29 min
  • Video: Subqueries in WHERE and FROM 10 min
  • Video: Common table expressions for readable queries 11 min
  • Article: Set operations: UNION, INTERSECT, EXCEPT 8 min
First steps with window functions 5 lessons · 46 min
  • Video: What a window function does 10 min
  • Video: Ranking with ROW_NUMBER, RANK and DENSE_RANK 11 min
  • Article: Running totals and moving averages 10 min
  • Video: Comparing periods with LAG and LEAD 9 min
  • Quiz: Final check 6 min

Requirements

  • No SQL experience needed
  • Comfort with spreadsheets helps
  • A computer where you can install PostgreSQL or Docker

Description

SQL is the most useful skill an analyst can learn, and it ages well: the queries you write today will still work in ten years. This course takes you from your first SELECT to window functions using a realistic dataset from a small online business, with customers, orders, products, refunds and the messy edges real data always has.

How we learn

Every lesson starts with a question someone at work might ask. Which products sold best last quarter? How many customers came back for a second purchase? What share of revenue came from each region? We answer it with SQL, then check the answer, because a query that runs is not the same as a query that is right.

  • Filtering, sorting and handling NULL correctly
  • Joins without accidentally multiplying rows
  • GROUP BY, HAVING and conditional aggregation
  • Dates, time zones and month by month reporting
  • Subqueries and common table expressions for readable queries
  • Window functions for rankings, running totals and period comparisons

Setup

We use PostgreSQL, free and widely used, with a ready made database you load in one command. Everything you learn transfers to MySQL, SQL Server, BigQuery, Snowflake and DuckDB, and I point out the small syntax differences as they come up.

Who this course is for

  • Analysts who currently work only in spreadsheets
  • Marketers, product managers and operations staff who need their own numbers
  • Developers who want stronger analytical SQL

Instructor

Aiko Tanaka

Analytics lead teaching SQL that answers business questions, from first SELECT to window functions

  • 4.4 instructor rating
  • 23 reviews
  • 6,830 students
  • 3 courses
  • Sample

I have spent most of my career turning vague questions into queries: which customers came back, where the funnel leaks, why revenue looks different in two reports. SQL is the tool I reach for first, and I teach it the way analysts actually use it.

My courses use realistic datasets with messy edges: duplicates, missing values, time zones and late data. You will learn to check your own results, explain a query to a colleague and keep cloud warehouse costs under control.

I write every exercise so it runs on free tools, PostgreSQL, DuckDB or the BigQuery sandbox, so you never need a company account to practise.

View profile

Student reviews

4.4 9 ratings
5 star 56%
4 star 33%
3 star 11%
2 star 0%
1 star 0%
Arjun K. Sep 26, 2026
Sample

Window functions without fear

Ranking and LAG explained with small examples before the real queries. I am no longer scared of OVER.

Tom B. Sep 17, 2026
Sample

The NULL lesson saved a report

I had a filter silently dropping rows with NULL. After lesson two I found it in a report my manager uses weekly.

Fatima Z. Aug 25, 2026
Sample

From spreadsheets to SQL in weeks

I only used Excel before. The questions in each lesson felt like my real work, and I now pull my own numbers.

Yuki S. Aug 6, 2026
Sample

Clear and well paced

Good for beginners. The cohort lesson was hard but rewarding, and I reused it at work the next day.

Chris W. Jul 15, 2026
Sample

Excellent first SQL course

Accurate, calm and practical. The comments with assumptions habit has made my queries much easier to share.

Ines A. Jul 3, 2026
Sample

Joins finally make sense

The lesson on joins multiplying rows explained why our revenue numbers never matched. A few more exercises would be nice.

Paulo R. May 11, 2026
Sample

Checking results is the best part

The routine for checking your own results is something I now do on every query.

Bianca L. Feb 20, 2026
Sample

Good content, setup was fiddly

The lessons are great, but getting PostgreSQL running on my work laptop took longer than expected.

Nadia E. Dec 2, 2025
Sample

Useful for product managers

I took this to stop waiting for the data team. Dates and time zones section was especially practical.

$39.99 Enroll now
SampleSample catalog: the instructors, courses, reviews and stats on this site are demo content.