A subquery is just a query contained inside another query. You can call the subquery an inner query contained within an outer query, which in turn can be a standard query or another subquery.
If you think about standard queries, you can define three kinds of queries, according to the type of result they provide:
Scalar—Queries that produce a single value (one single row with only one column)
List—Queries that produce a list of values (one or more rows with a single column only)
Array—Queries that return a result set (one or more rows with one or more columns)
List queries can be considered single-column array queries. Scalar queries can be used as single-column, single-row array queries as well.
Listing 11.1 shows different scalar queries ...