SQL (structured query language) is a practical way to access and manipulate data in a data warehouse. Analysts use it to draw from tables and views: tables hold records in rows and fields in columns, while views present curated query results that may combine underlying tables. Schemas organize tables. section 1.2.2
SELECT #1
state,
SUM(population) AS total_population
FROM city_populations
GROUP BY state
city_populations %>% #2
group_by(state) %>%
summarise(total_population = sum(population))
city_populations.groupby('state')['population'].sum() #3
Compare three ways to calculate total population by state. The SQL query selects a state, sums its population, and groups the result by state; the adjacent R and Python expressions perform the same aggregation. The listing is illustrative rather than runnable without the table. section 1.2.2
Familiarity with SQL can help an analyst explore an unfamiliar warehouse, although functions—particularly date functions—may differ between SQL dialects. SQL is also used to define schemas and tables, including their columns, data types, and constraints. In dbt, a model can combine a SQL query with table metadata and Jinja references to other models or warehouse sources. section 1.2.2 section 11.3.1
Keep the queries behind an analysis understandable and reusable. Recording how data was retrieved helps colleagues reproduce the work, supports stakeholder follow-ups, and avoids rewriting queries later. For a promotion analysis, documentation could identify the warehouse datasets used, explain exclusions, and describe the queries that retrieved the data. section 2.3.2 section 2.3.3
























