having clause in SQL

The HAVING clause specifies a search condition for a group or an aggregate. The HAVING clause is often used with the GROUP BY clause to filter groups or aggregates based on a specified condition.
The following statement illustrates the basic syntax of the HAVING clause:
```
SELECT
	column1,
	aggregate_function (column2)
FROM
	table_name
GROUP BY
	column1
HAVING
	condition;
```
In this syntax, the group by clause returns rows grouped by the column1. The HAVING clause specifies a condition to filter the groups.
It’s possible to add other clauses of the SELECT statement such as JOIN, LIMIT, FETCH etc.
SQL evaluates the HAVING clause after the FROM, WHERE, GROUP BY, and before the SELECT, DISTINCT, ORDER BY and LIMIT clauses.
```
SELECT
	customer_id,
	SUM (amount)
FROM
	payment
GROUP BY
	customer_id
HAVING
	SUM (amount) > 200;
```