1. dbt Labs Documentation
Glossary: While the dbt documentation focuses heavily on Common Table Expressions (CTEs) as a more readable alternative
it operates on the fundamental SQL principle that models are SELECT statements. Subqueries are a standard feature of SELECT statements. The dbt Glossary defines a model as "a single select statement
" and subqueries are a core component of how complex select statements are constructed.
Source: dbt Labs
"Glossary
" under the definition of "model." (URL: https://docs.getdbt.com/docs/glossary)
2. Snowflake Documentation (Official Vendor): Snowflake
a primary data platform for dbt
explicitly defines subqueries in its documentation.
Quote: "A subquery is a query within another query. The outer query is called the parent query
and the inner query is the subquery. The subquery is executed first
and the result of the subquery is used by the parent query."
Source: Snowflake Documentation
"Working with Subqueries." (URL: https://docs.snowflake.com/en/user-guide/queries-subqueries)
3. PostgreSQL Documentation (Official Vendor): PostgreSQL documentation provides a similar
authoritative definition.
Quote: "A subquery is a SELECT statement that is nested inside another statement... The subquery is executed and its result is substituted into the outer query."
Source: PostgreSQL 16 Documentation
Chapter 9: Functions and Operators
Section 9.23: "Subquery Expressions." (URL: https://www.postgresql.org/docs/current/functions-subquery.html)
4. Stanford University Courseware: Academic materials for database courses confirm this definition as a foundational concept.
Concept: Lecture notes for database courses like Stanford's CS145 (Introduction to Databases) define a subquery as a SELECT-FROM-WHERE expression nested inside another query
whose result is used by the containing query.
Source: Stanford University
CS145 Introduction to Databases
Lecture Notes on "Subqueries in SQL." (Example URL structure: https://web.stanford.edu/class/cs145/)