Skip to content

Track T30

SQL for Analysts

DuckDB SQL from first query to window functions.

Unit 1Reading tables

· 3 lessons
  1. 1Your first queryRead a table with SELECT, FROM and LIMIT, name what you compute, and use the SQL page's Tables list so you never mistype a table.Introductory · 7 min
  2. 2Filtering rows with WHEREKeep the rows you mean with WHERE, combine conditions, and learn why comparing with NULL finds nothing.Introductory · 8 min
  3. 3Sorting, top N and DISTINCTOrder rows, take the top few, handle ties and missing values, and list a column's distinct values.Introductory · 6 min

Unit 2Summarizing

· 2 lessons
  1. 4Summarizing with GROUP BYCollapse rows to one per group, know exactly which rows each aggregate counts, and spot when a summary hides a problem.Introductory · 8 min
  2. 5WHERE, HAVING and FILTERFilter rows before grouping, filter groups after, and count several conditions in one query.Applied · 7 min

Unit 3Combining tables

· 3 lessons
  1. 6Joining tablesCombine two tables on a key, choose what happens to rows with no match, and find them.Applied · 9 min
  2. 7When a join multiplies your rowsA key that isn't unique multiplies rows, and every total and average after it is wrong with no error. Learn to spot it and prevent it.Applied · 7 min
  3. 8Building up with WITHName intermediate results with WITH so a long query reads top to bottom, and use a subquery where a single number will do.Applied · 7 min

Unit 4Over rows and time

· 2 lessons
  1. 9Window functionsRank within groups, compare a row with the previous one, and smooth with a rolling average, all without losing a row.Applied · 9 min
  2. 10Dates and timesBuild real dates, group them by month, measure gaps, and notice when a date has been stored as text.Applied · 7 min

Unit 5Keep it honest

· 2 lessons
  1. 11Checking data with SQLWrite the queries that catch duplicates, coded values and inconsistent categories, turn them into data checks that keep watching, and add or export the checks the profile suggests.Applied · 12 min
  2. 12From a query to something that lastsParameterize a query, read its plan, save it, and promote it to a dataset, a notebook or a SQL model with tests and lineage.Applied · 9 min