DataLane

All stacks · Languages & local engines

SQL

Query patterns, window functions, and modeling.

SQL cover

Related reading

About SQL

SQL is the one skill in data engineering that has never stopped compounding. Every warehouse, lakehouse, and streaming engine converges on it, and the gap between adequate SQL and fluent SQL shows up directly in pipeline cost, correctness, and how long code review takes.

The articles here go past syntax: window functions used the way production models use them, join semantics that stop duplicate-row bugs, query anti-patterns that quietly multiply warehouse spend, and the modeling patterns — deduplication, sessionization, SCDs — that repeat in every stack.

What you'll learn here

  • Window functions from ranking basics to sessionization and percent-change patterns
  • Join mechanics and the fan-out bugs that silently double revenue numbers
  • CTEs, recursion, and readable query structure at production scale
  • Anti-patterns that destroy performance and how to rewrite them
  • Dialect differences across Snowflake, BigQuery, Postgres, and DuckDB

Frequently asked questions

Is SQL enough to get a data engineering job?

SQL plus one orchestration tool and one cloud platform is a credible junior profile — and interviews weight SQL heavily because it is hard to fake. Strong window-function fluency alone puts you ahead of a surprising share of candidates.

What SQL comes up most in interviews?

Deduplication with row_number, top-N per group, running totals and moving averages, gaps-and-islands, and join questions designed to expose fan-out misunderstandings. Our interview section drills each with worked solutions.

Why did my join double my totals?

The right side was not unique on the join key, so each left row matched multiple right rows — the classic fan-out. Check grain before joining: if the key is not unique, aggregate or dedupe first. This one bug pays for all the time you spend learning grain discipline.

Are CTEs slower than subqueries?

In modern warehouses, generally no — most optimizers inline CTEs, so structure queries for readability. The exception is recursive CTEs and engines that materialize CTEs referenced multiple times; measure before contorting your SQL.

How do I practice without a company warehouse?

Use the free SQL playground on this site — SQLite in your browser with realistic orders, customers, and events tables — or DuckDB locally over public Parquet datasets. Both cover 95% of interview-relevant SQL.

New SQL posts, straight to your inbox

One email a week with our latest tutorials. No spam.

Newsletter signup is not live yet. Use the contact form if you want to be notified.

↑↓ navigate openesc close