PostgreSQL HAVING clause is used to return the groups of rows only when the condition is TRUE. It is used with the PostgreSQL GROUP BY Clause. It, however, does not have a mandatory existence with the PostgreSQL GROUP BY Clause.
Syntax: To group the rows by values in multiple columns.
SELECT expressions FROM table_name GROUP BY columns HAVING having_conditions;
having_conditions: It is used to specify the conditions that are applied to the result obtained by the GROUP BY command, to restrict the result set.
SELECT “RATE” FROM “EMPLOYMENT” GROUP BY “RATE” HAVING COUNT (“RATE”) > 1 ORDER BY “RATE”;
RATE 60 70
The EMPLOYMENT is an already existing table from which we are retrieving unique employment rates with count greater than 1 using the HAVING condition with the GROUP BY clause.