O'Reilly logo

Microsoft® SQL Server™ 2000 Programming by Example by Carlos Eduardo Rojas, Fernando G. Guerrero

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Subqueries

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required