Read Me

Why this site

I love SQL. For most data transformations in a data warehouse it is also the fastest tool available: the work runs where the data already sits, close to the engine, with no rows shuffled in and out of an application layer. This site collects practical SQL for data warehousing, meant as inspiration for how data engineers can put it to work.

A reference architecture

There are many ways to build a data warehouse, and one page cannot cover them all. The examples here follow a single architecture that has proven reliable over the years:

  • Staging Layer: Landing Zone and Persistent Staging Area (PSA)
  • Integration Layer: Data Vault, split into Raw Vault and Business Vault
  • Presentation Layer: dimensional modeling

It serves as a consistent reference, not a rulebook. Adapt it freely to your own setup.

How to use this site

Pick your preferred database in the header. As you browse the topics, code examples are shown for that database wherever they exist.

On an individual example you can also switch to another database on the spot to compare quickly. That switch stays local to the example: your preferred database remains selected, so the rest of your navigation keeps showing it without you having to switch back.

About the examples

Coverage is incomplete. Where a database has no example for a topic, it usually means I have not added one yet. The same approach is most likely still possible there.

Databases keep evolving. New features arrive, behavior shifts, optimizers improve. A given example may already have a better solution by the time you read it. Treat the code as a solid starting point and a guide toward a good solution.

Everything is tested. I run each example before publishing. Even so, errors can slip through, so check the code against your own environment before you rely on it.