The HAVING clause is used in SQL to filter groups of rows after aggregation.
It works like WHERE, but it operates on grouped data after GROUP BY.
SELECT column1, aggregate_function(column2)
FROM table_name
GROUP BY column1
HAVING condition;
GROUP BY groups the result set by one or more columns.HAVING filters the grouped records based on an aggregate function or condition.SELECT department, COUNT(*)
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
WHERE filters before grouping, HAVING filters after grouping.HAVING is typically used with aggregate functions like COUNT, SUM, AVG, MAX, and MIN.WHERE and HAVING together in a query.SELECT city, AVG(salary)
FROM employees
GROUP BY city
HAVING AVG(salary) > 70000;
Describe the problem, challenge, or topic discussed in a video related to SELECT FROM.
What concept was explained or what exercise was solved?
-- Write your SQL code attempt or solution related to SQL COMMAND
SQL COMMAND
SQL COMMAND
Explanation - Explain what you learned, any key takeaways, or how you solved the problem related to COMMAND._
⬅️ Previous: AVG OPERATOR Next ➡️ SUBQUERY WITH AGGREGATE FUNCTIONS