The Oracle HAVING Clause is used with GROUP BY clause, because aggregate functions could not be used with WHERE keyword. The HAVING clause is often used with the GROUP BY clause to filter groups based on a specified condition.
To filter groups based on a specified condition, use the following syntax:
Parameters:
tablename: The table name from which you want to fetch the records.
condition: To specify the conditions that must be fulfilled for the records to be selected.
HAVING: To sort data set in ascending order.
ORDER BY: To specify filter conditions for a group of rows or aggregates. It shows only those groups in result set whose conditions are TRUE.
aggregate_function: It specifies the aggregate functions i.e. SUM, COUNT, MIN, MAX or AVG functions.
Note:
In the above example, we have fetched records using filter groups based on a specified condition using HAVING.
Note:
In the above example, we have fetched records using filter groups based on a specified condition using HAVING.