Skip to content

Overview

Module 5: Writing Queries with EDU#

By the end of this module, you'll be able to answer a real analytics question: which day of the week has the lowest attendance for female students, by school? We'll build up to that query step by step — starting with a simple select, adding filters, joining tables together, and finally aggregating across dimensions.

Steps for building a query#

A good way to approach any query is to work through these steps before writing SQL:

  1. Define the purpose of the query — What question are you answering? Who will use the result?
  2. Identify key tables — Which fact and dimension tables hold the data you need? Use Data domains and key tables or dbt Docs to find them.
  3. Determine relevant columns and filters — What do you need to select? What filters (e.g., school year, school, demographic) apply?
  4. Decide if joins or aggregates are needed, and at what grain — Do you need to join to dimensions for labels? Do you need to aggregate (e.g., count, sum, rate)? What should one row in your result represent?
  5. Put it all together — Write the SQL (select, from, joins, where, group by, order by).
  6. Check your work — Run the query, spot-check results, and confirm row counts and grain make sense.

The sections below walk through the mechanics of selects, filters, joins, and aggregates; keeping this process in mind will help you apply them deliberately.

Need a refresher on the workspace layout?

If you jumped straight to this module, check out Module 4: Inside a Workspace for a walkthrough of the editor, database explorer, output pane, and how to preview data.


⏸️ Pause: Choose your own path#

You're ready to start writing queries. The following sections build up your SQL skills progressively, but you should go at your own pace.

New to SQL?

Start from the beginning and work through each section in order. Each section builds on the previous one, using a consistent example that grows in complexity.

Already comfortable with SQL?

Feel free to skip ahead to Joins and Analytics Examples. Even if you know SQL well, these sections contain important EDU-specific context about:

  • How EDU tables are structured and named
  • Best practices for joining EDU fact and dimension tables
  • Common pitfalls and patterns specific to the EDU warehouse
  • How to work with EDU's surrogate keys and table conventions

Section overview#

Level Section Description
Beginner Your First Select Learn to select columns from tables and use limit while exploring
Intermediate Filtering, Grouping & Ordering Filter rows, group data, and order results
Intermediate Joins Combine data from multiple tables (includes EDU-specific patterns)
Advanced Analytics Examples See how all the pieces come together in realistic EDU queries (highly recommended for all skill levels)

Building toward one question

Throughout these sections, we'll build up one complete example piece by piece: starting with student names, filtering to specific demographics, joining to attendance and school data, and finally answering our goal question about day-of-week attendance patterns. Each section adds a new layer, so you can see how queries evolve from simple to complex. Even if you skip ahead, you'll see references to this progression in the examples.