

# `HAVING` clause

The `HAVING` clause filters the groups that `GROUP BY` forms, after the aggregates are computed. Its condition can use aggregate functions, grouping expressions, and the aliases of the select list.

## Syntax
<a name="athena-duckdb-statement-select-having-syntax"></a>

```sql
HAVING {{condition}}
```

## Examples
<a name="athena-duckdb-statement-select-having-examples"></a>

For a description of the sample tables that the examples on this page use, see [SELECT statement in DuckDB](duckdb-statement-select.md).

The following SQL query returns the regions whose total amount is more than 100.

```sql
SELECT region, sum(amount) AS revenue
FROM sales_db.sales_parquet
GROUP BY region
HAVING sum(amount) > 100
ORDER BY region
```

The query returns the following results.


| region | revenue | 
| --- | --- | 
| `east` | `162.75` | 
| `north` | `310.00` | 

The following SQL query filters on `orders`, the alias of an aggregate in the select list.

```sql
SELECT region, count(*) AS orders
FROM sales_db.sales_parquet
GROUP BY region
HAVING orders > 1
ORDER BY region
```

The query returns the following results.


| region | orders | 
| --- | --- | 
| `east` | `3` | 
| `west` | `2` | 