In this section, we will learn how to examine the following types of subqueries:
Subqueries such as the ones we've seen so far are known as scalar or single-row
subqueries because the subquery returns a single value to the outer query. This single value replaces the condition in the WHERE
clause. When writing statements that use subqueries, we say that certain types of queries expect either a single value or multiple values. The previous statement expects one value, as the WHERE
clause can only be evaluated properly if one value is returned. For instance, let's say that we want a list of websites with the average highest hit counts on Companylink grouped by the website description. To attempt this, we write a statement using a subquery as shown:
When we run the statement, an error is returned. Even though the inner query is syntactically correct, it returns more values than can be evaluated by a single WHERE
statement. Thus, an...