Aggregate functions can be used with ............ clause. They can not be used…
2025
Aggregate functions can be used with ............ clause. They can not be used with ............ clause.
- A.
WHERE, HAVING/
- B.
HAVING, WHERE
- C.
GROUP BY, HAVING
- D.
SELECT, HAVING
Attempted by 937 students.
Show answer & explanation
Correct answer: B
Aggregate functions like COUNT, SUM, AVG, MIN, MAX are used to perform calculations on a set of values and return a single value. They are typically used in SQL queries to summarize data. Step 1: Aggregate functions can be used with the GROUP BY clause. This clause groups rows that have the same values in specified columns into summary rows, and aggregate functions are applied to each group. Step 2: Aggregate functions can also be used with the HAVING clause. HAVING filters groups after the GROUP BY operation, and since it operates on aggregated data, it can use aggregate functions. Step 3: Aggregate functions cannot be used with the WHERE clause. WHERE filters rows before any grouping occurs, so it does not have access to aggregated values. Therefore, aggregate functions are not allowed in the WHERE clause. Conclusion: Aggregate functions can be used with GROUP BY and HAVING clauses, but not with WHERE clause.