Where can sub queries be used?

Where can sub queries be used? (Choose all that apply)

Where can sub queries be used? (Choose all that apply)

A.
field names in the SELECT statement

B.
the FROM clause in the SELECT statement

C.
the HAVING clause in the SELECT statement

D.
the GROUP BY clause in the SELECT statement

E.
the WHERE clause in only the SELECT statement

F.
the WHERE clause in SELECT as well as all DML statements

Explanation:
SUBQUERIES can be used in the SELECT list and in the FROM, WHERE, and HAVING clauses
of a query.
A subquery can have any of the usual clauses for selection and projection. The following are
required clauses:
A SELECT list
A FROM clause
The following are optional clauses:
WHERE
GROUP BY
HAVING
The subquery (or subqueries) within a statement must be executed before the parent query that
calls it, in order that the results of the subquery can be passed to the parent.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Vincent LaBarge

Vincent LaBarge

It seems to me that subqueries cannot be used in the Order By clause. Is that correct?

Eric

Eric

Yes, sir ! 😀
A subquery is a query that is nested inside a SELECT, INSERT, UPDATE, or DELETE
statement or inside another subquery. A subquery can return a set of rows or just one
row to its parent query. A scalar subquery is a query that returns exactly one value:
a single row, with a single column. Scalar subqueries can be used in most places in
a SQL statement where you could use an expression or a literal value.
The places in a query where a subquery may be used are as follows:
â–  In the SELECT list used for column projection
â–  In the FROM clause
â–  In the WHERE clause
â–  In the HAVING clause
* Page 358 (SQL Fundamentals I Exam Guide)