> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baenninger.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Filtern

Die `HAVING`-Klausel wurde zu SQL hinzugefügt, da das `WHERE`-Keyword nicht mit den Aggregatsfunktionen genutzt werden kann.

```sql theme={null}
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);
```

### Beispiel

Dieser Query listed die Anzahl Kunden in jedem Land auf, absteigend sortiert. Zudem inkludiert es nur Länder mit mehr als 5 Kunden.

```sql theme={null}
SELECT COUNT(*), Country
FROM Customers
GROUP BY Country
HAVING COUNT(*) > 5
ORDER BY COUNT(*) DESC;
```
