Class - 12 CBSE Computer Science — Assertion Reason Type Questions
Assertion. Both WHERE and HAVING clauses work with GROUP BY in a SELECT statement.
Reason. The WHERE clause is applied before forming groups of rows and HAVING clause is applied after forming the groups.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
SQL Queries
1 Like
Answer
Both A and R are true and R is the correct explanation of A.
Explanation
Both the WHERE
and HAVING
clauses can be used with the GROUP BY
clause in a SELECT
statement to filter and specify conditions for rows and groups, respectively. The WHERE
clause filters rows before they are grouped, while the HAVING
clause filters groups of rows after they have been grouped by the GROUP BY
clause. This is because WHERE
conditions cannot include aggregate functions, whereas HAVING
conditions can include them.
Answered By
1 Like