Which two statements are true about the WHERE and HAVING clauses in a SELECT statement?
A.
The WHERE clause can be used to exclude rows after dividing them into groups
B.
WHERE and HAVING clauses can be used in the same statement only if applied to different table columns.
C.
The HAVING clause can be used with aggregating functions in subqueries.
D.
Aggregating functions and columns used in HAVING clauses must be specified in these SELECT list of a query.
E.
The WHERE clause can be used to exclude rows before dividing them into groups.
The Answer Is:
D, E
This question includes an explanation.
Explanation:
In SQL, the WHERE and HAVING clauses are used to filter records; the WHERE clause is applied before grouping the records, while the HAVING clause is used after grouping the records, particularly when using aggregation functions.
Statement D is true because the HAVING clause is used to filter groups based on the result of aggregate functions. Therefore, any column or aggregate function appearing in the HAVING clause must also appear in the SELECT list of the query, unless it is used as part of an aggregate function.
Statement E is true because the WHERE clause is designed to filter rows before they are grouped into aggregate groups in a GROUP BY clause. This is a fundamental aspect of SQL that optimizes query performance by reducing the number of rows to be processed in the aggregate phase.
Statements A, B, and C are incorrect based on the following:
A is incorrect because the WHERE clause does not operate on groups but on individual rows before grouping.
B is misleading; while WHERE and HAVING can be used in the same statement, their usage is not restricted to different columns. They perform different functions (row-level filtering vs. group-level filtering).
C is incorrect because subqueries using aggregate functions typically do not use HAVING clauses; rather, HAVING is used in the outer query to filter the results of aggregates.
1z0-071 PDF/Engine
Printable Format
Value of Money
100% Pass Assurance
Verified Answers
Researched by Industry Experts
Based on Real Exams Scenarios
100% Real Questions
Get 60% Discount on All Products,
Use Coupon: "8w52ceb345"