31271 Lecture Notes - Lecture 10: Embedded Sql, Aggregate Function

94 views2 pages
5 Jun 2018
School
Course
Professor
Lecture 10: SQL IV
Subqueries can be noncorrelated (executed once for the entire outer query), or they can be
correlated (executed once for each row which is returned by the outer query).
A correlated subquery will refer back to elements found from the outer query:
Whereas non correlated subqueries do not depend on the data from the outer query.
A correlated subquery can use the EXISTS operator.
o The EXISTS operator returns TRUE if the subquery resulted in a non-empty set.
Particularly for correlated subqueries it is imperative that the tables have aliases to refer to
from inside the subquery.
Subquery in From Clause
You can have a subquery in the From clause. By calculating an aggregate function within the
FROM clause/subquery you can use this within the following WHERE clause which would not
initially be allowed to have an aggregate function.
Query Efficiency
When using a select clause, specify the attributes you wish to return rather than using
SELECT* as this reduces network traffic.
Subqueries affect efficiency, so try to keep everything to a limited number of queries.
Better Query Design
Write simple queries, and break complex ones into multiple simple parts.
Don’t nest ueies
If possible, avoid self joins
Retrieve only the data that you need.
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents