Gaps and islands finally clicked
The hand worked table for the row number difference trick made it obvious. I used it for login streaks the same week.
Browse
Solve hard analytical problems in SQL, from gaps and islands to recursive CTEs, and make slow queries fast by reading query plans
Created by Aiko Tanaka
You already write joins, aggregations and simple window functions. This course is about the problems that come next: sessions from raw click events, streaks and gaps, funnels with strict ordering, hierarchies of unknown depth, and the query that worked fine last year and now takes four minutes.
Each pattern is introduced with a small table you can reason about by hand, then applied to a larger realistic dataset of web events and subscriptions. We use PostgreSQL 17 for the examples and highlight syntax that differs in BigQuery, Snowflake and DuckDB, such as QUALIFY.
The tuning section is practical rather than theoretical. You will take slow queries, read their plans, form a hypothesis, change one thing and measure again. That loop is the skill, and it works on any database.
Analytics lead teaching SQL that answers business questions, from first SELECT to window functions
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.
The hand worked table for the row number difference trick made it obvious. I used it for login streaks the same week.
We replaced a slow Python job with the SQL sessionization pattern from this course. It is faster and easier to review.
I never understood why my running totals repeated values on the same day. The RANGE versus ROWS lesson explained it perfectly.
Five slow queries, five fixes, each measured. That lesson alone sped up three of our dashboards.
Reading plans from the bottom up with BUFFERS was very practical. A bit PostgreSQL focused, which is fine for me.
The funnel lesson was hard and very good. I would have liked one more exercise on recursive CTEs.
Clearly expert material. Section five moved quickly and I needed to pause a lot, but everything was correct.