Access Millions of academic & study documents

Sql subqueries

Content type
User Generated
School
usc
Showing Page:
1/18

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/18

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/18

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 18 pages?
Access Now
Unformatted Attachment Preview
Writing Subqueries SQL BASICS – WRITING QUERIES NESTED IN ANOTHER QUERY Subqueries A subquery is a SELECT expression that you embed inside one of the clauses of a SELECT statement to form your final query statement • The SQL Standard defines three types of subqueries: • Row subquery—an embedded SELECT expression that returns more than one column and no more than one row • Table subquery—an embedded SELECT expression that returns one or more columns and zero to many rows • Scalar subquery—an embedded SELECT expression that returns only one column and no more than one row 2 Scalar Subqueries • You can embed a scalar subquery in the list of expressions immediately following the SELECT keyword • A scalar subquery is a SELECT expression that returns exactly one column and no more than one row • You’re substituting the subquery where you would normally enter a single column name or expression that results in a single column 3 Using Scalar Subqueries • A subquery used in this way lets you pluck a single value from some other table or query to include in the output of your query • You don’t need to reference the table or query that is the source of the data in the FROM clause of the subquery at all in the FROM clause of the outer query • In most cases, you will need to add criteria in the WHERE clause of the subquery to make certain it returns no more than one row • You can even have the criteria in the subquery reference a value being retur ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4