danny22.com

Labs

SQL Lab

Learn to answer business questions from the gold marts of a group data platform. Write queries, learn analysis patterns, define every metric in one definition file, and build and maintain production dashboards. The goal is not to know a lot of syntax but to recognize why the same question can give different numbers, and to make sure anyone who reruns the work gets the same ones.

Status
Updated 2026-11-17 KST · 1 of 1 units written. A one-page plan is written. The parts, unit counts, data and tools are not yet agreed and may change. There is no full unit list or unit text yet
Size
Planned as 6 parts and about 30 units (29 core, 1 advanced), each a 60 to 90 minute session. Units are numbered volume-part-chapter (V00-P01-C03); from V00-P01 on, the first unit of each part (C00) is that part's map
Audience
Analysts and business practitioners. People new to SQL can follow along with a short review at the start of V00-P02
Cases
Questions asked by the subsidiaries of the fictional holding company danny22.com: repeat purchases and the definition of an "active customer" in retail, station flows in mobility, and year-over-year demand in energy. The subsidiaries and people are made up and unrelated to real companies
Data
Real public data, with synthetic data we generate only for what public data cannot provide (web and app events). Candidates include UCI Online Retail II, Seoul public bike rental records and EIA-930 electricity demand; how much of each to use is not yet agreed
Language
The course material is written in Korean
Access
sql-lab.danny22.com, open to signed-in readers. Get in touch to request access

What you learn

  • Writing queries that are right: selection and aggregation, NULL and missing values, joins and grain, fan-out that inflates totals after a join, times and dates, and window functions and ties.
  • Analysis patterns: cohorts and retention, funnels, sessionization, time series comparisons such as year over year and moving averages, and rankings and contribution such as top N and Pareto.
  • Defining metrics in one place: write each metric into a metric definition file, handle metrics with two definitions and metrics that cannot be added up (distinct counts, ratios), and test and change the definitions.
  • Building and maintaining dashboards: build an analyst's small mart in a sandbox, publish a dashboard that leads with the conclusion, keep freshness and failure indicators working, and retire dashboards nobody looks at.

What a unit contains

  • Theory: concepts, diagrams and numbers measured on this machine.
  • Notebook: queries run for real, ending in a check cell that judges the result: does the query match the answer table, and does the value from the metric definition file match hand-written SQL?
  • Metric definitions and dashboard source: the metrics the unit adds to the definition file and the source of its dashboard.

Parts

The course works from the top down. V00-P01 takes one business question all the way through a gold mart query, a single metric and a one-page dashboard, to show what the rest is for; from V00-P02 it goes deeper in order: queries, analysis patterns, the definition file and dashboards. Data Lab builds the marts, this lab uses them to produce metrics, and Stats Lab asks whether those numbers can be trusted.

PartWhat you learnUnits
V00-P00 Getting startedThe syllabus, where this lab sits on the common skeleton for data problem solving and what it leaves behind (the metric definition file and dashboards), and the way of working used throughout3
V00-P01 A thin first passQuerying "first-time customers rarely buy again" from a gold mart, adding the 30-day repeat purchase rate to the definition file and publishing it as a one-page dashboard. What this version cannot do becomes the outline for V00-P02 onward4
V00-P02 QueriesSelection and aggregation, NULL and missing values, joins, grain and fan-out, times and dates (UTC and Korean time, leap years), window functions (ROWS and RANGE, ties), readable queries, and tests against answer tables6
V00-P03 Analysis patternsCohorts and retention, funnels, sessionization, time series comparison (year over year, moving averages), ranking and contribution (top N, Pareto)6
V00-P04 Metric definitionsFilling in the definitions (MetricFlow), metrics with two definitions, metrics that cannot be added up (distinct counts, ratios), testing and changing definitions5
V00-P05 Marts and dashboardsWriting analyst marts (sandbox), building dashboards, dashboards that lead with the conclusion, operations (freshness, failure indicators, checking use and retiring). The advanced unit compares OLAP cubes and server-based BI6

While planning, we ran real queries on the candidate data. In UCI Online Retail II, dropping orders with no customer ID gives a first-month retention of 18.9% for the 2010 cohort; counting those orders as customers gives 12.6%. Causes like this, where one question yields different numbers, are what the lab is built on.