Oracle__10. Oracle 1Z0-051 Exam - Subquery Flashcards
What is a nested subquery?
A subquery in the WHERE clause
What is an inline view?
A subquery in the FROM clause
What is necessary about the return value of a subquery in a SELECT clause that is not necessary of a subquery in either a FROM or a WHERE clause?
A subquery in a SELECT clause can only return a single row.Termed: single-row subquery
How would you modify this SQL Statement to the minimum is greater than the average for all items in the table? SELECT item_no, AVG(qty) FROM table1 HAVING AVG(qty) > MIN(qty) * 2 GROUP BY item_no
A subquery is needed.SELECT item_no, MIN(qty)FROM table1HAVING MIN(qty) > (Select AVG(qty) FROM table1)GROUP BY item_no
Can a subquery within a subquery return multiple rows?
Yes
If there are 2 employees named Smith what will be returned by this statement? SELECT * FROM employees WHERE emp_name = (SELECT emp_name FROM employees)
errorBecause the subquery will return more than one record
Which is executed first, main query or the subquery?
subquery
Can the main query and subquery get data from different tables?
yes
What clause cannot be included when the insert statement has a subquery?
VALUES clause
The SOME operator is a synonym for what other operator?
ANY
What does it mean when a value is compared to a subquery using the < ANY operator?
The value will be compared to the maximum value returned from the subquery.
What does it mean when a value is compared to a subquery using the > ANY operator?
The value will be compare to the minimum value returned from the subquery.
What does it mean when a value is compared to a subquery using the = ANY operator?
= ANY operator is equivalent to the IN operator
What does it mean when a value is compared to a subquery using the < ALL operator?
The value will be compare to the maximum value returned from the subquery.
What does it mean when a value is compared to a subquery using the > ALL operator?
The value will be compare to the minimum value returned from the subquery.
What does it mean when a value is compared to a subquery using the = ALL operator?
= ALL operator is invalid
Can the NOT operator be used with IN, ANY and ALL operators?
Yes
Can the ANY operator be used with multiple-row subqueries?
Yes
Can the ALL operator be used with multiple-row subqueries?
Yes
Can the main query and the subquery get data from different tables?
Yes
Are subqueries required to return only one column?
NoExample of 2 columns compared:WHERE (name, age) in (Select name, age from table1)
Can subqueries contain GROUP BY and ORDER BY clauses?
Yes
Can you use an expression as a return in a subquery?
YesExample of an expression returned from a subquery:WHERE (name, limit) in (Select name, 12 * 4 from table1)Note: no alias is needed, just need same number of values and same data types to compare