# Structure analytical SQL with readable reusable CTEs Separate filtering, normalization and aggregation into named CTEs, then check the execution plan so readability does not hide repeated scans or higher cost. - Canonical: https://satracking.net/guides/bigquery-ctes-reusable-analysis/ - Language: en - Category: platforms - Level: intermediate - Published: 2026-11-14 - Updated: 2026-11-14 --- Separate filtering, normalization and aggregation into named CTEs, then check the execution plan so readability does not hide repeated scans or higher cost. It focuses on clear definitions, correct analytical scope and checks that make conclusions reproducible. ## Define the analytical question State the decision or question the analysis must support. Specify the population, unit of analysis, time window and metric scope. Identify the source fields and transformations required, and record assumptions that could change the result. ## Apply a repeatable method Separate source filtering, normalization, event extraction, aggregation and final output into named stages; use explicit columns and aliases; avoid repeated expensive scans; comment business rules; test intermediate CTE outputs. ## Check interpretation and edge cases A CTE improves readability but does not guarantee materialization or lower cost. Inspect the execution plan and avoid repeating heavy transformations unnecessarily. Validate the result with a small known example, inspect missing or duplicated records, and compare equivalent periods and populations. Keep the denominator visible and distinguish observed behavior from causal explanation. ## Make the analysis reproducible Record the report configuration, query or exploration settings, source freshness and definition version. Share a concise interpretation with limitations and next actions. Re-run the same checks after material tracking, schema or business-process changes. ## Review checklist - Is the population, grain and time window explicit? - Do the selected fields match the intended scope? - Have duplicates, missing values and boundary cases been checked? - Are limitations and assumptions visible? - Can another analyst reproduce the result? ## Official references - Query syntax (WITH clause) — https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax (verified 2026-11-23) - Subqueries — https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/subqueries (verified 2026-11-23)