Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

Summary Queries within Queries This chapter covered the nesting of a query inside another query, a powerful tool that you can use when faced with tricky data extraction questions. Specifically, this chapter covered the following topics: ❑ A subquery is just like a normal query, with SELECT clauses, WHERE statements, and GROUP BY and HAVING clauses. ❑ Subqueries can be included in a SELECT statement’s column listing, or they can be used inside a WHERE statement to enable results to be filtered. ❑ Aggregate functions are commonly used with subqueries because a subquery must normally return just one record for each record in the main query. ❑ A subquery can return multiple rows when used with an IN, ANY, ALL, or EXISTS operator. These operators function as follows: ❑ The IN operator is used to find out whether a value is in one of the values returned by a subquery. ❑ The ANY operator allows a comparison between a value and any of the values returned by a subquery. Comparisons are not limited to just equals (=); rather, you can use any comparison operator, such as greater than (>), less than (

Summary<br />

Queries within Queries<br />

This chapter covered the nesting of a query inside another query, a powerful tool that you can use when<br />

faced with tricky data extraction questions. Specifically, this chapter covered the following topics:<br />

❑ A subquery is just like a normal query, with SELECT clauses, WHERE statements, and GROUP BY<br />

and HAVING clauses.<br />

❑ Subqueries can be included in a SELECT statement’s column listing, or they can be used inside a<br />

WHERE statement to enable results to be filtered.<br />

❑ Aggregate functions are commonly used with subqueries because a subquery must normally<br />

return just one record for each record in the main query.<br />

❑ A subquery can return multiple rows when used with an IN, ANY, ALL, or EXISTS operator.<br />

These operators function as follows:<br />

❑ The IN operator is used to find out whether a value is in one of the values returned by a<br />

subquery.<br />

❑ The ANY operator allows a comparison between a value and any of the values returned<br />

by a subquery. Comparisons are not limited to just equals (=); rather, you can use any<br />

comparison operator, such as greater than (>), less than (

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!