Which two statements are true about WHERE and HAVING clauses? (Choose two)
A.
A WHERE clause can be used to restrict both rows and groups.
B.
A WHERE clause can be used to restrict rows only.
C.
A HAVING clause can be used to restrict both rows and groups.
D.
A HAVING clause can be used to restrict groups only.
E.
A WHERE clause CANNOT be used in a query of the query uses a HAVING clause.
F.
A HAVING clause CANNOT be used in sub queries.
Explanation:
B: WHERE clause cannot be use to restrict groups
WHERE clause cannot be use when there is group functions.
D: A HAVING clause can only e used to restrict GROUPS.
Note: HAVING clause to specify which groups are to be displayed and thus further restrict the groups on
the basis of aggregate information. The Oracle server performs the following steps when you use the Having
clause
1. rows are grouped
2. the group function is applied to the group
3. the group that match the criteria in the Having clause are displayed.
Incorrect Answers :
A:
Where clause cannot be use to restrict groups
C:
A HAVING clause can only e used to restrict GROUPS.
E:
WHERE clause cannot be use when there is group function, instead HAVING is to be use.
F:
There is no constraint to use HAVING clause in a sub queries.
Refer: Introduction to Oracle9i: SQL, Oracle University Student Guide, Aggregating Data using Group
Functions, p. 5-20